NAME
OX::Application::Role::RouteBuilder - application role to configure a router based on a static description
VERSION
version 0.13
SYNOPSIS
package MyApp;
use Moose;
use Bread::Board;
extends 'OX::Application';
with 'OX::Application::Role::RouteBuilder',
'OX::Application::Role::Path::Router';
sub BUILD {
my $self = shift;
container $self => as {
service root => (
class => 'Foo::Root',
);
service 'RouterConfig' => (
block => sub {
+{
'/' => {
class => 'OX::RouteBuilder::ControllerAction',
route_spec => {
controller => 'root',
action => 'index',
},
params => {},
},
'/foo' => {
class => 'OX::RouteBuilder::Code',
route_spec => sub { 'FOO' },
params => {},
},
}
},
);
};
}
DESCRIPTION
NOTE: unless you are building new framework bits, you probably want to use OX::Application::Role::RouterConfig instead, which provides some nicer syntax for some common route builders.
This role provides a RouterConfig
service for your application container, which should contain a description of all of the routes your application will be handling. This description must be a hashref, where the keys are paths and the values are hashrefs with class
, route_spec
, and params
keys. class
determines which OX::RouteBuilder class to use to parse this route, route_spec
is a description of the route itself, and params
provides a hashref of extra data (for instance, with OX::Application::Role::Router::Path::Router, params
holds the Path::Router defaults and validations).
METHODS
parse_route($path, $route)
This method takes a path and a route description as described above and returns a new OX::RouteBuilder instance which will handle creating the routes. By default it creates an instance of $route->{class}
, passing in the $path
, $route->{route_spec}
, and $route->{params}
as arguments, but you can override this in your app to provide more features.
AUTHORS
Stevan Little <stevan.little@iinteractive.com>
Jesse Luehrs <doy@tozt.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Infinity Interactive.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.