[cgiapp] Re lease CGI::Application::Plugin::Header
Ryo Anazawa
anazawa at kuc.biglobe.ne.jp
Mon Mar 25 23:31:05 EDT 2013
Thanks for your reply.
I wouldn't use a '-' prefix, too, and so I'll remove the prefix from
SYNOPSIS.
I agree we shouldn't promote it. SYNOPSIS should be as follows:
sub do_something {
my $self = shift;
my $type = $self->header('type'); # getter
# setter
$self->header(
charset => 'utf-8',
type => 'text/plain,
);
}
However, CGI.pm' header() method requires the prefix in some cases:
use CGI qw/header/;
print header( type => 'text/plain' ); # broken!
# [STDOUT]
# Status: text/plain
# Content-Type: type; charset=ISO-8859-1
As Mark says, I think we need to support it silently or quietly.
Thanks for your suggestion!
Best regards,
Ryo
Ron Savage wrote:
>
> Hi Ryo
>
> Why on earth do you use a '-' prefix on parameters?
>
> That is user-hostile code, like the '--' required on the command line
> for (some) apps.
>
> Yes, I know that many, many years ago '--' was used to distinguish
> between command line parsers, where the original used '-', but that's a
> red herring these days.
>
>
> On 26/03/13 05:55, Ryo Anazawa wrote:
>>
>> Hi all,
>>
>> Thanks for maintaining CGI::Application.
>>
>> I'll release yet another CGI::Application plugin,
>> CGI::Application::Plugin::Header, on CPAN soon.
>> This plugin adds the header() method to your CGI app which helps you
>> handle
>> CGI.pm-comptible HTTP header properties.
>> Since header() is compatible with the existing handlers such as
>> header_type,
>> header_props, header_add,
>> it will not break your application.
>>
>> You can use header() as follows:
>>
>> package MyApp;
>> use parent 'CGI::Application';
>> use CGI::Application::Plugin::Header 'header';
>>
>> sub do_something {
>> my $self = shift;
>>
>> my $type = $self->header('-type'); # getter
>>
>> # setter
>> $self->header(
>> -charset => 'utf-8',
>> -type => 'text/plain,
>> );
>>
>> my $header = $self->header; # returns CGI::Header::Props object
>> }
>>
>> FEATURE
>>
>> - You can pass key-value pairs of header props. to header().
>> Unlike header_props(), header() *merges* the pairs into the existing
>> header props.
>>
>> - CGI::Header::Props implements push_cookie() and push_p3p() methods.
>> These
>> methods behave like CGI::Application#header_add.
>>
>> - Normalizes property names automatically ("-Content_Type" -> "-type"),
>> and
>> so you can specify them consistently.
>>
>> CAP::Header is still in development. You can download the latest code in
>> the
>> following repository:
>>
>> https://github.com/anazawa/p5-CGI-Header-Props
>>
>> I'm waiting for your suggestions. Patches are welcome :)
>>
>> Thanks,
>> Ryo
>>
>
> --
> Ron Savage
> http://savage.net.au/
> Ph: 0421 920 622
>
> ##### CGI::Application community mailing list ################
> ## ##
> ## To unsubscribe, or change your message delivery options, ##
> ## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
> ## ##
> ## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
> ## Wiki: http://cgiapp.erlbaum.net/ ##
> ## ##
> ################################################################
>
>
>
--
View this message in context: http://old.nabble.com/Release-CGI%3A%3AApplication%3A%3APlugin%3A%3AHeader-tp35216388p35217908.html
Sent from the cgiapp at lists.openlib.org mailing list archive at Nabble.com.
More information about the cgiapp
mailing list