MooseX::Types::HTTPMethod - Type constraints for HTTP method names
use Moose; use MooseX::Type::HTTPMethod qw(HTTPMethod11 HTTPMethod); has rest_query_type => ( is => 'ro', isa => HTTPMethod11, ); has request_type => ( is => 'ro', isa => HTTPMethod, ); print "GET is an HTTP/1.1 method: ", (is_HTTPMethod11('GET') : 1 : 0), "\n"; # prints 1 print "PATCH is an HTTP/1.1 method: ", (is_HTTPMethod11('FOO') : 1 : 0), "\n"; # prints 0 print "GET is an HTTP method: ", (is_HTTPMethod('GET') : 1 : 0), "\n"; # prints 1 print "PATCH is an HTTP method: ", (is_HTTPMethod('PATCH') : 1 : 0), "\n"; # prints 1
This module implements string types which validate against all HTTP method names currently defined by RFCs. Multiple types are available, encompassing various specifications:
HTTP methods defined by HTTP 1.0: GET, POST, HEAD
HTTP methods defined by HTTP 1.1: HTTP 1.0 plus OPTIONS, PUT, DELETE, TRACE and CONNECT
All HTTP methods currently defined by RFCs (HTTP 1.1 plus a whole lot more, mostly for WebDAV protocols)
As with all MooseX::Types types, the inclusion of one type name
'Foo' in the
use line will result in an import of these functions:
returns the type itself (an object implementing the Moose::Meta::TypeConstraint interface), and
a function returning a bool, checking if the passed value validates against the
Bugs may be submitted through https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Types-HTTPMethod. I am also usually active on irc, as 'ether' at irc://irc.perl.org.
Karen Etheridge <firstname.lastname@example.org>
This software is copyright (c) 2013 by Karen Etheridge.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.