Jesse Luehrs > OX-0.14 > OX::Application::Role::Request

Download:
OX-0.14.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.14   Source  

NAME ^

OX::Application::Role::Request - application role to allow the use of request and response objects

VERSION ^

version 0.14

SYNOPSIS ^

  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
          );
      };
  }

DESCRIPTION ^

This role provides some helper methods for handling request and response objects in your application.

METHODS ^

request_class

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_request($env)

Creates a new instance of the request class for the given PSGI environment.

handle_response($response, $request)

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.

AUTHORS ^

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.

syntax highlighting: