The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

OX::Application::Role::Router - base role for applications with routers

VERSION

version 0.14

DESCRIPTION

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.

This role also defines the ox.router key in the PSGI environment, so that the application code and middleware can easily access the router.

METHODS

router_class

Required method which should return the class name which the router object itself will be an instance of.

app_from_router

Required method which should take a router instance and return a PSGI application coderef.

router

This method returns the router instance that is in use. It is equivalent to $app->resolve(service => 'Router').

build_router($service)

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.

configure_router($router)

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).

router_dependencies

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.

AUTHORS

  • Stevan Little <stevan.little@iinteractive.com>

  • Jesse Luehrs <doy@tozt.net>

COPYRIGHT AND LICENSE

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.