NAME

    Spike-2.0 - simple Plack::Request-based web framework

SYNOPSIS

 Quick start

    1. Install Spike package

    2. spike add MySite

    3. cd MySite

    4. rm -r web/mysite

    5. ln -s /path/to/web/static/files web/mysite

    6. plackup script/mysite.psgi

 Simple site

  startup.psgi

        use FindBin;
        use lib "$FindBin::Bin/../lib";
    
        use DeadBeef::Site;
    
        DeadBeef::Site->run;

  DeadBeef::Site

        package DeadBeef::Site;
    
        use base qw(Spike);
        use HTTP::Status qw(:constants);
    
        sub startup {
            my $self = shift;
    
            $self->route
                ->prepare(sub {
                    my ($req, $res) = @_;
                    # place code here
                })
                ->finalize(sub {
                    my ($req, $res) = @_;
                    # place code here
                })
                ->error(HTTP_NOT_FOUND() => sub {
                    my ($req, $res) = @_;
                    # place code here
                })
                ->error(HTTP_INTERNAL_SERVER_ERROR() => sub {
                    my ($req, $res) = @_;
                    # place code here
                })
                ->get('/' => sub {
                    my ($req, $res) = @_;
                    # place code here
                })
                ->post('/' => sub {
                    my ($req, $res) = @_;
                    # place code here
                });
        }
    
        1;

 Routes and handlers

        $new_route = $route->route('level1')
        $new_route = $route->route('level1/level2/...')
        $new_route = $route->route('*')
        $new_route = $route->route('#name')
        $new_route = $route->route('#name' => [qw(value1 value2 ...)])
        $new_route = $route->route('#name' => qr/regexp/ })
        $new_route = $route->route('#name' => sub { ... })
    
        # all of the above together
        $new_route = $route->route('l1/#n1/l3' => sub { ... })
            ->route('*/#n2/l6' => sub { ... })
    
        $route = $route->get(sub { ... })
        $route = $route->get('path' => sub { ... })
        $route = $route->post(sub { ... })
        $route = $route->post('path' => sub { ... })
        $route = $route->all(sub { ... })
        $route = $route->all('path' => sub { ... })
    
        $route = $route->error(sub { ... })
        $route = $route->error(404 => sub { ... })
        $route = $route->error(Spike::Error::Class => sub { ... })
    
        $route = $route->prepare(sub { ... })
        $route = $route->finalize(sub { ... })

SEE ALSO

    Plack, Plack::Request, Plack::Response

AUTHOR

    Aleksandr Aleshin <silencer2k@gmail.com>

COPYRIGHT

    Copyright (c) 2016 Aleksandr Aleshin

LICENSE

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

