[cgiapp] Re lease CGI::Application::Plugin::Header

Mark Stosberg mark at summersault.com
Mon Mar 25 17:37:31 EDT 2013


On 03/25/2013 05:04 PM, Ron Savage wrote:
> Hi Ryo
> 
> Why on earth do you use a '-' prefix on parameters?

While I wouldn't use the "-" prefix in documentation or otherwise
promote it, I could see silently or quietly *supporting* it, if one one
of your objectives is to be CGI.pm-compatible.

He stated that one of his goals is "CGI.pm-comptible HTTP header
properties."

I'll take a look at the code. Thanks for the contribution, Ryo.

   Mark


> 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
>>
> 



More information about the cgiapp mailing list