NAME
Drogo - Lightweight web framework
SYNOPSIS
Kick-start a project: drogo --create=[projectname]
or
app.psgi:
use Drogo::Server::PSGI;
use Example::App;
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 );
Example::App->handler( server => $server );
}
};
Example/App.pm:
package Example::App;
use strict;
use Drogo::Dispatch( auto_import => 1 );
sub init
{
my $self = shift;
$self->{foo} = 'bar';
}
sub primary :Index
{
my $self = shift;
$self->header('text/html'); # default
$self->status(200); # defaults to 200 anyways
$self->print('Welcome!');
$self->print(q[Go here: <a href="/moo">Mooville</a>]);
}
# referenced by /foo
sub foo :Action
{
my $self = shift;
my $stuff = $self->param('stuff');
$self->print('Howdy!');
}
# referenced by /moo/whatever
sub moo :ActionMatch
{
my $self = shift;
my @post_args = $self->post_args;
$self->print('Howdy: ' . $post_args[0]);
}
METHODS
$self->server
Returns the server object.
$self->uri
Returns the uri.
$self->module_url
Returns the url associated with the module.
$self->filename
Returns the path filename.
$self->request_method
Returns the request_method.
$self->remote_addr
Returns the remote_addr.
$self->header_in
Return value of header_in.
$self->print(...)
Output via http.
$self->auto_header
Returns true if set, otherwise args 1 sets true and 0 false.
$self->dispatching
Returns true if we're dispatching actively.
$self->header_set('header_type', 'value')
Set output header.
$self->header('content-type')
Set content type.
$self->headers
Returns hashref of headers.
$self->location('url')
Redirect to a url.
$self->status(...)
Set output status... (200, 404, etc...) If no argument given, returns status.
$self->request_part(...)
Returns reference for upload.
{
'filename' => 'filename',
'tmp_file' => '/tmp/drogomp-23198-1330057261',
'fh' => \*{'Drogo::MultiPart::$request_part{...}'},
'name' => 'foo'
}
$self->param(...)
Return a parameter passed via CGI--works like CGI::param.
$self->param_hash
Return a friendly hashref of CGI parameters.
$self->request_body & $self->request
Returns request body.
$self->request_parts
Returns arrayref of request parts, used for multipart/form-data requests.
$self->args
Returns args.
$self->post_args
Returns array of post_arguments (matching path after a matched ActionMatch attribute)
process_auto_header
Process the autoheader.
error_stack
Returns the "error stack" as an array.
get_error
Returns error as string.
$self->unescape
Unscape HTTP URI encoding.
$self->cookie
Cookie methods:
$self->cookie->set(-name => 'foo', -value => 'bar');
my %cookies = $self->cookie->read;
$self->elapsed_time
Returns elapsed time since initial dispatch.
COPYRIGHT
Copyright 2011, 2012 Ohio-Pennsylvania Software, LLC.
LICENSE
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.