NAME
Drogo::Server::PSGI - Implement a Drogo PSGI application.
METHODS
new
Create a new server instance.
Parameters: env => the PSGI environment hash, respond => the PSGI responder (optional; enables streaming),
Example app.psgi file.
my $app = sub {
my $env = shift;
return sub {
my $respond = shift;
# create new server object
my $server = Drogo::Server::PSGI->new( env => $env, respond => $respond );
# set default application package
$server->variable( app_package => 'dev' );
# do something with server...
Example::App->handler( server => $server );
}
};
Without a respond callback the dispatch returns a plain PSGI response array reference, which suits non-streaming servers and tests.
initialize
Initializes Drogo instance.
input
Returns input stream.
process_request_method
Processes a post.
cleanup
Cleanup processing.
variable(key => $value)
Returns a persistant server variable.
Key without value returns variable.
These include variables set by the server configuration, as "user variables" in nginx.
uri
Returns the uri (PATH_INFO, without the mount prefix).
script_name
Returns the mount prefix (SCRIPT_NAME).
args
Returns string of arguments.
request_body
Returns the request body (used for posts)
request_method
Returns the request method (GET or POST)
remote_addr
Returns remote address.
has_request_body
Used by nginx for request body processing.
This function is only called when the request method is a post, in an effort to reduce processing time.
header_in
Returns a request header.
header_out
Sets a header out. Setting the same header again keeps both values, so repeated headers such as Set-Cookie are all sent.
send_http_header
Send the http header.
$self->status(...)
Set output status... (200, 404, etc...) If no argument given, returns status.
Print stuff to the http stream.
sleep
Sleeps (used by nginx), not needed for other server implementations.
header_only
Returns true of only the header was requested.
unescape
Unescape an encoded uri.
server_return
This function defines what is returned to the server at the end of a dispatch. For nginx, this will be a status code. Here, with a respond callback the streaming writer is closed; without one a PSGI response array reference is returned.
AUTHORS
Bizowie <http://bizowie.com>
COPYRIGHT AND LICENSE
Copyright (C) 2013 Bizowie
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.