Jedi::App - Jedi App
version 0.08
This module allow you to define apps. Apps is plug above roads, and with receive the end of the path (without the road).
You can reused easily apps, like admin panel, or anything, and plug it into any based road you want.
package MyApps; use Jedi::App; use JSON; sub jedi_apps { my ($jedi) = @_; $jedi->get('/', $jedi->can('index')); $jedi->get('/env', $jedi->can('display_env')); $jedi->get(qr{/aaa/}, $jedi->can('aaa')); return; } sub index { my ($jedi, $request, $response) = @_; $response->status("200"); $response->body("Hello World !"); return 1; } sub display_env { my ($jedi, $request, $response) = @_; $response->status('200'); $response->body(to_json($request->env)); return 1; } sub aaa { my ($jedi, $request, $response) = @_; $response->status(200); $response->body("AAA !"); } 1;
If this is plug with :
$jedi->road('/test');
This will return :
/test # Hello World ! /test/ # Hello World ! /test/env # JSON of env variables /test/env/ # JSON of env variables
And also the regexp works
/test/helloaaaworld # AAA !
This module is equivalent into your package to :
package MyApps; use Moo; with "Jedi::Role::App"; with "Jedi::Role::Config";
You can access to the config from your apps. Use the attribute "jedi_config".
See Jedi::Role::Config for more defails
You can access to the jedi_env config from your apps. Use the attribute "jedi_env".
Jedi::Role::App
Jedi::Role::Config
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.
celogeek <me@celogeek.com>
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.
To install Jedi, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jedi
CPAN shell
perl -MCPAN -e shell install Jedi
For more information on module installation, please visit the detailed CPAN module installation guide.