Dancer::HTTP(3) helper for rendering HTTP status codes for Dancer

VERSION

version 1.3202

DESCRIPTION

Helper for rendering HTTP status codes for Dancer

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'

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., 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';
        }
        ...
    };

Processed Codes

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

Problem with request

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

Problem with server

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

AUTHOR

This module has been written by Alexis Sukrieh <[email protected]>

SOURCE CODE

The source code for this module is hosted on GitHub <https://github.com/PerlDancer/Dancer>

LICENSE

This module is free software and is published under the same terms as Perl itself.

AUTHOR

Dancer Core Developers

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.