GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Router::Simple::Sinatraish(3) User Contributed Perl Documentation Router::Simple::Sinatraish(3)

Router::Simple::Sinatraish - Sinatra-ish routers on Router::Simple

    package MySinatraishFramework;
    use Router::Simple::Sinatraish;
    
    sub import {
        Router::Simple::Sinatraish->export_to_level(1);
    }

    sub to_app {
        my ($class) = caller(0);
        sub {
            my $env = shift;
            if (my $route = $class->router->match($env)) {
                return $route->{code}->($env);
            } else {
                return [404, [], ['not found']];
            }
        };
    }

    package MyApp;
    use MySinatraishFramework;

    get '/' => sub {
        [200, [], ['ok']];
    };
    post '/edit' => sub {
        [200, [], ['ok']];
    };
    any '/any' => sub {
        [200, [], ['ok']];
    };

    __PACKAGE__->to_app;

Router::Simple::Sinatraish is toolkit library for sinatra-ish WAF.

my $router = YourClass->router;
Returns this instance of Router::Simple.

get($path:Str, $code:CodeRef)
    get '/' => sub { ... };
    

Add new route, handles GET method.

post($path:Str, $code:CodeRef)
    post '/' => sub { ... };
    

Add new route, handles POST method.

any($path:Str, $code:CodeRef)
    any '/' => sub { ...  };
    

Add new route, handles any HTTP method.

any($methods:ArrayRef[Str], $path:Str, $code:CodeRef)
    any [qw/GET DELETE/] => '/' => sub { ...  };
    

Add new route, handles any HTTP method.

Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>

Router::Simple

Copyright (C) Tokuhiro Matsuno

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

2022-04-08 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.