Dancer::HTTP(3pm) | User Contributed Perl Documentation | Dancer::HTTP(3pm) |
Dancer::HTTP - helper for rendering HTTP status codes for Dancer
version 1.3521
Helper for rendering HTTP status codes for Dancer
Returns the numerical status of $status.
# all three are equivalent, and will return '405' $x = Dancer::HTTP->status( 405 ); $x = Dancer::HTTP->status( 'Method Not Allowed' ); $x = Dancer::HTTP->status( 'method_not_allowed' );
Returns a hashref of all HTTP status known to "Dancer". The keys are the numerical statuses and the values their string equivalents.
print Dancer::HTTP->codes->{404}; # prints 'File Not Found'
The following codes/aliases are understood by any status() call made from a Dancer script. The aliases can be used as-is (e.g., Moved Permanently), or as lower-case string with all non-alphanumerical characters changed to underscores (e.g., moved_permanently).
get '/user/:user' => sub { my $user = find_user( param('user') ); unless ( $user ) { status 404; # or could be status 'not_found'; # or even status 'Not Found'; } ... };
This module has been written by Alexis Sukrieh <sukria@cpan.org>
The source code for this module is hosted on GitHub <https://github.com/PerlDancer/Dancer>
This module is free software and is published under the same terms as Perl itself.
Dancer Core Developers
This software is copyright (c) 2010 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2023-02-10 | perl v5.36.0 |