=for stopwords inline
=head1 NAME
HTTP::Router - Yet Another Path Router for HTTP
=head1 SYNOPSIS
use HTTP::Router;
my $router = HTTP::Router->new;
my $route = HTTP::Router::Route->new(
path => '/',
conditions => { method => 'GET' },
params => { controller => 'Root', action => 'index' },
);
$router->add_route($route);
# or
$router->add_route('/' => (
conditions => { method => 'GET' },
params => { controller => 'Root', action => 'index' },
));
# GET /
my $match = $router->match($req);
$match->params; # { controller => 'Root', action => 'index' }
$match->uri_for; # '/'
=head1 DESCRIPTION
HTTP::Router provides a way of constructing routing tables.
If you are interested in a Merb-like constructing way,
please check L<HTTP::Router::Declare>.
=head1 METHODS
=head2 new
Returns a HTTP::Router object.
=head2 add_route($route)
=head2 add_route($path, %args)
Adds a new route.
You can specify L<HTTP::Router::Route> object,
or path string and options pair.
example:
my $route = HTTP::Router::Route->new(
path => '/',
conditions => { method => 'GET' },
params => { controller => 'Root', action => 'index' },
);
$router->add_route($route);
equals to:
$router->add_route('/' => (
conditions => { method => 'GET' },
params => { controller => 'Root', action => 'index' },
));
=head2 routes
Returns registered routes.
=head2 reset
Clears registered routes.
=head2 freeze
Creates inline matcher using registered routes.
=head2 thaw
Clears inline matcher.
=head2 is_frozen
Returns true if inline matcher is defined.
=head2 match($req)
Returns a L<HTTP::Router::Match> object that matches a given request.
If no routes match, it returns C<undef>.
=head2 route_for($req)
Returns a L<HTTP::Router::Route> object that matches a given request.
If no routes match, it returns C<undef>.
=head1 AUTHOR
NAKAGAWA Masaki E<lt>masaki@cpan.orgE<gt>
Takatoshi Kitano E<lt>kitano.tk@gmail.comE<gt>
=head1 LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
L<HTTP::Router::Declare>, L<HTTP::Router::Route>, L<HTTP::Router::Match>,
L<MojoX::Routes>, L<http://merbivore.com/>,
L<HTTPx::Dispatcher>, L<Path::Router>, L<Path::Dispatcher>
=cut