Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
Router::Boom::Method(3User Contributed Perl DocumentatiRouter::Boom::Method(3)

NAME
       Router::Boom::Method - Router::Boom with	HTTP method support

DESCRIPTION
       Router::Boom doesn't care the routing with HTTP method. It's simple and
       good.  But it makes hard	to implement the rule like this:

	   get	'/' => sub { 'get ok'  };
	   post	'/' => sub { 'post ok' };

       Then, this class	helps you.

METHODS
       "my $router = Router::Boom::Method->new()"
	   Create new instance.

       "$router->add($http_method:Str|ArrayRef[Str], $path:Str,	$opaque:Any)"
	   Add new path	to the router.

	   $http_method	is a string to represent HTTP method. i.e. GET,	POST,
	   DELETE, PUT,	etc.  The path can handle any HTTP methods, you'll
	   path	the "undef" for	this argument.	You can	specify	the multiple
	   HTTP	methods	in ArrayRef like "$router->add([qw(GET HEAD)], '/',
	   'top')".  It	will be	matching with the "REQUEST_METHOD".

	   $path is the	path string. It	will be	matching with the "PATH_INFO".

	   $opaque is the destination path data. Any data is OK.

       "my ($dest, $captured, $is_method_not_allowed, $allowed_methods)	=
       $router->match($http_method:Str,	$path:Str)"
	   Matching with the router.

	   $http_method	is the HTTP request method. It's
	   "$env->{REQUEST_METHOD}" in PSGI.

	   $path is the	path string. It's "$env->{PATH_INFO}" in PSGI.

	   Return Value:

	   If the request is not matching with any path, this method returns
	   empty list.

	   If the request is matched well then,	return $dest, $captured. And
	   $is_method_not_allowed is false value.

	   If the request path is matched but the $http_method is not matched,
	   then	$dest and $captured is undef. And $is_method_not_allowed is
	   true	value. You got this then you need to return "405 Method	Not
	   Allowed" error.

	   If the request path is matched but the $http_method is not matched,
	   then	$dest and $captured is undef. And $allowed_methods is
	   ArrayRef. You got this then you need	to return "405 Method Not
	   Allowed" error with "Allow" header.

       "my $regexp = $router->regexp()"
	   Get a compiled regexp for debugging.

       "my @routes = $router->routes()"
	   EXPERIMENTAL

	   Get the list	of registered routes. Every routes has following
	   schema.

	       [Maybe[ArrayRef], Str, Any]

	   For example:

	       [['GET','HEAD'],	"/foo",	\&dispatch_foo]

AUTHORS
       Tokuhiro	Matsuno

perl v5.24.1			  2017-07-02	       Router::Boom::Method(3)

NAME | DESCRIPTION | METHODS | AUTHORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=Router::Boom::Method&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help