OX::Application::Role::Router - base role for applications with routers
version 0.14
This is an abstract role for creating applications based on a router. You probably want to use OX::Application::Role::Router::Path::Router instead, unless you need to use a different router.
This role adds a Router service to the application container, which can be configured by the build_router and router_dependencies methods. It also overrides build_app to automatically build a PSGI application from the routes in the router.
Router
build_router
router_dependencies
build_app
This role also defines the ox.router key in the PSGI environment, so that the application code and middleware can easily access the router.
ox.router
Required method which should return the class name which the router object itself will be an instance of.
Required method which should take a router instance and return a PSGI application coderef.
This method returns the router instance that is in use. It is equivalent to $app->resolve(service => 'Router').
$app->resolve(service => 'Router')
This method is called by the Router service to create a new router instance. By default, it calls new on the specified router_class. It is passed the Router service object, so that you can access the resolved dependencies you specify in router_dependencies.
new
router_class
This method is called after a new router is instantiated, to allow you to add routes to the router (or do whatever other configuration is necessary).
This method returns a hashref of dependencies, as described in Bread::Board. The arrayref form of dependency specification is not currently supported. These dependencies can be accessed in the build_router method.
Stevan Little <stevan.little@iinteractive.com>
Jesse Luehrs <doy@tozt.net>
This software is copyright (c) 2014 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.