Dancer::HTTP - helper for rendering HTTP status codes for Dancer
Contents
Copyright And License
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.
perl v5.36.0 2023-02-10 Dancer::HTTP(3pm)
Description
Helper for rendering HTTP status codes for Dancer
Http Codes
The following codes/aliases are understood by any status() call made from a Dancer script. The aliases
can be used as-is (e.g., MovedPermanently), 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';
}
...
};
ProcessedCodes
200 - OK
201 - Created
202 - Accepted
204 - No Content
205 - Reset Content
206 - Partial Content
Redirections
301 - Moved Permanently
302 - Found
304 - Not Modified
306 - Switch Proxy
Problemwithrequest
400 - Bad Request
401 - Unauthorized
402 - Payment Required
403 - Forbidden
404 - Not Found
405 - Method Not Allowed
406 - Not Acceptable
407 - Proxy Authentication Required
408 - Request Timeout
409 - Conflict
410 - Gone
411 - Length Required
412 - Precondition Failed
413 - Request Entity Too Large
414 - Request-URI Too Long
415 - Unsupported Media Type
416 - Requested Range Not Satisfiable
417 - Expectation Failed
Problemwithserver
500 - Internal Server Error
Also aliases as 'error'.
501 - Not Implemented
502 - Bad Gateway
503 - Service Unavailable
504 - Gateway Timeout
505 - HTTP Version Not Supported
License
This module is free software and is published under the same terms as Perl itself.
Methods
status($status)
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' );
codes
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'
Name
Dancer::HTTP - helper for rendering HTTP status codes for Dancer
Source Code
The source code for this module is hosted on GitHub <https://github.com/PerlDancer/Dancer>
Version
version 1.3521
