[Catalyst] proposed plugin for http status codes

John Napiorkowski jjn1056 at yahoo.com
Sat Jul 8 15:05:09 CEST 2006


Hey,

I've been using this homegrown plugin locally to make it easier to set http status codes and to check for certain http return values.  Basically it adds the stuff in "http://search.cpan.org/~gaas/libwww-perl-5.805/lib/HTTP/Status.pm" to the $c->response namespace, so you can do something like:

$c->response->status($c->response->RC_NOT_FOUND);

or

if( $->response->is_success($c->response->status) ) {...}

Personally I find this useful and easier to remember than all the numbers.  Also easier to debug. 

HTTP::Status is pretty common since it comes with LWP so I think this is an easy module to install.  However it makes liberal use of EXPORT instead of EXPORT_OK so it brings bunches of stuff into the namespace.  So what I am asking is:

1)  Would other people find it useful for me to bundle this up as a regular plugin and put it out on CPAN.
2) Assuming 1) is yes are you all happy with the way I am doing this?  In particular I am hoping that someone who is in charge of Catalyst::Response will let me know if they are cool will all those constants being imported into the common namespace.  I'm guessing not but the alternative seems worse; ie I could make this something like $c->response->status_codes->RC_NOT_FOUND but that may be more verbose than a friendly framework would like :)

I've attached the plugin as I am using it.  As you will see it's trivial.  Thanks for comments and suggestions.

-JOHN

-------------- next part --------------
A non-text attachment was scrubbed...
Name: http_status.pm
Type: application/octet-stream
Size: 688 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20060708/0ff48825/attachment.obj 


More information about the Catalyst mailing list