OX::Application::Role::RouteBuilder - application role to configure a router based on a static description
version 0.13
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 => {}, }, } }, ); }; }
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).
RouterConfig
class
route_spec
params
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.
$route->{class}
$path
$route->{route_spec}
$route->{params}
Stevan Little <stevan.little@iinteractive.com>
Jesse Luehrs <doy@tozt.net>
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.
To install OX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OX
CPAN shell
perl -MCPAN -e shell install OX
For more information on module installation, please visit the detailed CPAN module installation guide.