NAME

Jedi::Role::App - Jedi App Role

VERSION

version 0.01

DESCRIPTION

This role is to apply to your Moo module.

use Moo;
with 'Jedi::Role::App';

You should use the Jedi::App module.

METHODS

get

Define a GET method.

$jedi->get("/", sub{...});

post

Define a POST method.

$jedi->post("/", sub{...});

put

Define a PUT method.

$jedi->put("/", sub{...});

del

Define a DEL method.

$jedi->del("/", sub{...});

missing

If no route matches, all the missing method is executed.

$jedi->missing(sub{...});

response

This will solve the route, and run all the method found.

If none is found, we run all the missing methods.

The route continue until a "false" response it sent. That should always mean an error.

$jedi->response($request, $response);

ROUTES

GET/POST/PUT/DELETE

All the methods, take a route, and a sub.

The route can be a scalar (exact match) or a regexp.

The sub take Jedi::App, a Jedi::Request and a Jedi::Response.

Each sub should fill the Response based on the Request.

The return code should be "1" if everything goes fine, to let other matching route to apply their changes.

If the return is "0" or undef (false), the route stop and return the response.

You should only use the bad return if something goes wrong.

You can have multiple time the same route catch (thought regexp, and exact match). Each one receive a response, and pass this response to the next sub.

BUGS

Please report any bugs or feature requests on the bugtracker website https://tasks.celogeek.com/projects/perl-modules-jedi

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

celogeek <me@celogeek.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by celogeek <me@celogeek.com>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.