Catalyst::TraitFor::Request::Methods - Add enumerated methods for HTTP requests
version v0.2.3
In the Catalyst class
__PACKAGE__->config( request_class_traits => [ 'Methods' ] );
In any code that uses a Catalyst::Request, e.g.
if ($c->request->is_post) { ... }
This trait adds enumerated methods from RFC 7231 and RFC 5789 for checking the HTTP request method.
Using these methods is a less error-prone alternative to checking a case-sensitive string with the method name.
In other words, you can use
$c->request->is_get
instead of
$c->request->method eq "GET"
The methods are implemented as lazy read-only attributes.
The request method is GET.
GET
The request method is HEAD.
HEAD
The request method is POST.
POST
The request method is PUT.
PUT
The request method is DELETE.
DELETE
The request method is CONNECT.
CONNECT
The request method is OPTIONS.
OPTIONS
The request method is TRACE.
TRACE
The request method is PATCH.
PATCH
Catalyst::Request
The development version is on github at https://github.com/robrwo/Catalyst-TraitFor-Request-Methods- and may be cloned from git://github.com/robrwo/Catalyst-TraitFor-Request-Methods-.git
Please report any bugs or feature requests on the bugtracker website https://github.com/robrwo/Catalyst-TraitFor-Request-Methods-/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Robert Rothenberg <rrwo@cpan.org>
This software is Copyright (c) 2019-2020 by Robert Rothenberg.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install Catalyst::TraitFor::Request::Methods, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::TraitFor::Request::Methods
CPAN shell
perl -MCPAN -e shell install Catalyst::TraitFor::Request::Methods
For more information on module installation, please visit the detailed CPAN module installation guide.