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
http_status.pm
Description: Binary data
_______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
