NAME

Web::Dispatcher::Simple - Minimalistic routing sugar for your Plack

SYNOPSIS

In Web::Dispatcher::Simple, a route is an HTTP method paired with an URL matching pattern. Each route is associated with a code ref:

# app.psgi
use Web::Dispatcher::Simple;
my $app = router {
  get '/api' => sub {
    my $req = shift;
    my $res = $req->new_response(200);
    $res->body('Hello world');
    $res;
  },
  post '/comment/{id}' => sub {
    my ($req, $args)  = @_;
    my $id = $args->{id};
    my $res = $req->new_response(200);
    $res;
  },
  any [ 'GET', 'POST' ] => '/any' => sub {
      my ( $req, $args ) = @_;
      my $res = $req->new_response(200);
      $res->body('any');
      $res;
  }, 
};

Route patterns may include named parameters, accessible via the args hash:

use Web::Dispatcher::Simple;
my $app = router {
  post '/comment/{id}' => sub {
    my ($req, $args)  = @_;
    my $id = $args->{id};
    my $res = $req->new_response(200);
    $res;
  },
};

DESCRIPTION

Web::Dispatcher::Simple is Minimalistic routing sugar for your Plack

SOURCE AVAILABILITY

This source is in Github:

http://github.com/dann/p5-web-dispatcher-simple

CONTRIBUTORS

Many thanks to: woremacx

AUTHOR

dann <techmemo@gmail.com>

SEE ALSO Router::Simple, Plack

LICENSE

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