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

Ron Savage ron at savage.net.au
Mon Mar 25 17:04:45 EDT 2013


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


More information about the cgiapp mailing list