OX::Application - base class for OX applications
version 0.04
package MyApp; use Moose; extends 'OX::Application'; sub build_app { return sub { [ 200, [], ["Hello world"] ] }; } MyApp->new->to_app; # returns the PSGI coderef
This class provides the base set of functionality for OX applications. OX::Application is a subclass of Bread::Board::Container, so all Bread::Board functionality is available through it.
By default, the container holds two services:
This service provides an arrayref of middleware to be applied, in order, to the app (the first middleware in the array will be the outermost middleware in the final built app). It is built via the build_middleware and middleware_dependencies methods, described below.
build_middleware
middleware_dependencies
Middleware can be specified as either a coderef (which is expected to accept an app coderef as an argument and return a new app coderef), the name of a subclass of Plack::Middleware, or a Plack::Middleware instance.
This service provides the actual PSGI coderef for the application. It is built via the build_app and app_dependencies methods described below, and applies the middleware from the Middleware service afterwards. It also applies Plack::Middleware::HTTPExceptions as the innermost middleware, so your app can throw HTTP::Throwable or HTTP::Exception objects and have them work properly.
build_app
app_dependencies
Middleware
You can add any other services or subcontainers you like, and can use them in the construction of your app by overriding build_middleware, middleware_dependencies, build_app, and app_dependencies.
This method can be overridden in your app to provide an arrayref of middleware to be applied to the final application. It is passed the Middleware service object, so that you can access the resolved dependencies you specify in middleware_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_middleware method.
This method must be overridden by your app to return a PSGI coderef. It is passed the App service object, so that you can access the resolved dependencies you specify in app_dependencies.
App
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_app method.
This method returns the final PSGI application, after all middleware have been applied. This method is just a shortcut for $app->resolve(service => 'App').
$app->resolve(service => 'App')
Stevan Little <stevan.little at iinteractive.com>
Jesse Luehrs <doy at cpan dot org>
This software is copyright (c) 2012 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.