Programming:Perl:Jedi:Hello World

From Knowledge base
Revision as of 00:22, 12 March 2018 by Celogeek (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Perl Jedi, is a web app framework, with no DSL. It doesn't create new magic keywords. The good point is that it avoids conflict with other packages.

Also Perl Jedi do the minimum to dispatch your request to your methods, and return a PSGI compatible response.

You can install your Jedi::App like any other package and then run the launcher to start your app.

A Jedi::App is simple as a Moo package.

I will show you a hello world in Perl Jedi!

MyHelloWorld.pm:

package MyHelloWorld;
use Jedi::App;

sub jedi_app {
 my ($app) = @_;
 $app->get('/', sub {
  my ($app, $request, $response) = @_;
  $response->status(200);
  $response->body('Hello World !');
  return 1;
 });
}

1;

hello_world.yml:

Jedi:
  Roads:
    MyHelloWorld: /

Now you can start your app :

$ perl-jedi -c hello_world.yml

Run a curl command :

$ curl "http://localhost:5000/"
Hello World !


Share your opinion