OX::Application::Role::Request - application role to allow the use of request and response objects
version 0.14
package MyApp; use Moose; extends 'OX::Application'; with 'OX::Application::Role::Request'; sub build_app { my $self = shift; return sub { my $env = shift; my $r = $self->new_request($env); return $self->handle_response( MyApp::Controller->new->do_action($r), $r ); }; }
This role provides some helper methods for handling request and response objects in your application.
This method can be overridden to provide your own custom request class. Defaults to OX::Request.
This request class is expected to provide a new_response method, so overriding the response class to use can be done by overriding this method in your request class.
new_response
Creates a new instance of the request class for the given PSGI environment.
Takes a response provided by the application and turns it into a proper PSGI response arrayref. The default implementation of this method handles bare strings (turns them into a response with a code of 200 and a Content-Type header of text/html) and anything which can be provided to the new_response method of the request object. $request must be passed in addition to the actual response that was received in order to be able to call new_response.
Content-Type
text/html
$request
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.