README
1NAME
2 Router::Simple::Sinatraish - Sinatra-ish routers on Router::Simple
3
4SYNOPSIS
5 package MySinatraishFramework;
6 use Router::Simple::Sinatraish;
7
8 sub import {
9 Router::Simple::Sinatraish->export_to_level(1);
10 }
11
12 sub to_app {
13 my ($class) = caller(0);
14 sub {
15 my $env = shift;
16 if (my $route = $class->router->match($env)) {
17 return $route->{code}->($env);
18 } else {
19 return [404, [], ['not found']];
20 }
21 };
22 }
23
24 package MyApp;
25 use MySinatraishFramework;
26
27 get '/' => sub {
28 [200, [], ['ok']];
29 };
30 post '/edit' => sub {
31 [200, [], ['ok']];
32 };
33 any '/any' => sub {
34 [200, [], ['ok']];
35 };
36
37 __PACKAGE__->to_app;
38
39DESCRIPTION
40 Router::Simple::Sinatraish is toolkit library for sinatra-ish WAF.
41
42EXPORTABLE METHODS
43 my $router = YourClass->router;
44 Returns this instance of Router::Simple.
45
46EXPORTABLE FUNCTIONS
47 get($path:Str, $code:CodeRef)
48 get '/' => sub { ... };
49
50 Add new route, handles GET method.
51
52 post($path:Str, $code:CodeRef)
53 post '/' => sub { ... };
54
55 Add new route, handles POST method.
56
57 any($path:Str, $code:CodeRef)
58 any '/' => sub { ... };
59
60 Add new route, handles any HTTP method.
61
62 any($methods:ArrayRef[Str], $path:Str, $code:CodeRef)
63 any [qw/GET DELETE/] => '/' => sub { ... };
64
65 Add new route, handles any HTTP method.
66
67AUTHOR
68 Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>
69
70SEE ALSO
71 Router::Simple
72
73LICENSE
74 Copyright (C) Tokuhiro Matsuno
75
76 This library is free software; you can redistribute it and/or modify it
77 under the same terms as Perl itself.
78
79