Amon2

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

2.38 2011-06-14

    - optimize directory structure for dotcloud(tokuhirom).

2.37 2011-06-06

    - escape JSON data for IE7's Content-Type vulnerability.

2.36 2011-05-30

    - generate (404|50[023]).html for dotcloud.
    - auto_include considered harmful
    - Text::MicroTemplate is no longer required by Amon2 core.

2.35 2011-05-14

    - fixed deps: JSON 2 is required.
    - suppress warnings on t/100_core/010_add_config.t

2.34 2011-05-13

Changes  view on Meta::CPAN

2.30 2011-03-08

    - Amon2->add_config() was now deprecated.
    - Implement default load_config()
    - ConfigLoader is no longer needed
    - Depend to latest Xslate.
    - fixed testing issue

2.29 2011-03-06

    - better 404 page

2.28 2011-03-05

    - added Amon2::Setup::Asset::Blueprint
    - remove Plugin::Web::FillinForm from core. It will release as other dist.

2.27 2011-03-02

    - do not create MyApp/Web/(Request|Response).pm by default.
      It's makes shourter skelton code.

eg/apps/DeepNamespace/lib/DeepNamespace/Web/Admin/Dispatcher.pm  view on Meta::CPAN

package DeepNamespace::Web::Admin::Dispatcher;
use strict;

sub dispatch {
    my ($class, $c) = @_;
    if ($c->request->path_info eq '/') {
        return DeepNamespace::Web::Admin::C::Root->index($c);
    } else {
        return $c->res_404();
    }
}

1;

eg/apps/DeepNamespace/lib/DeepNamespace/Web/User/Dispatcher.pm  view on Meta::CPAN

package DeepNamespace::Web::User::Dispatcher;
use strict;

sub dispatch {
    my ($class, $c) = @_;
    if ($c->request->path_info eq '/') {
        return DeepNamespace::Web::User::C::Root->index($c);
    } else {
        return $c->res_404();
    }
}

1;

eg/apps/SampleApp/lib/SampleApp/Web/Dispatcher.pm  view on Meta::CPAN

package SampleApp::Web::Dispatcher;
use Amon2::Web::Dispatcher;

sub dispatch {
    my ($class, $c) = @_;
    if ($c->request->path_info eq '/') {
        return call("Root", 'index');
    } else {
        return res_404();
    }
}

1;

lib/Amon2/Setup/Flavor/Basic.pm  view on Meta::CPAN


    $self->render_file('.gitignore', 'Basic/dot.gitignore');
    $self->render_file('.proverc', 'Basic/dot.proverc');

    {
        my %status = (
            '503' => 'Service Unavailable',
            '502' => 'Bad Gateway',
            '500' => 'Internal Server Error',
            '504' => 'Gateway Timeout',
            '404' => 'Not Found'
        );
        while (my ($status, $status_message) = each %status) {
            $self->render_file(
                "static/$status.html",
                "Basic/static/__STATUS__.html",
                { status => $status, status_message => $status_message }
            );
        }
    }
}

lib/Amon2/Setup/Flavor/Large.pm  view on Meta::CPAN


    $self->render_file('.gitignore', 'Basic/dot.gitignore');
    $self->render_file('.proverc', 'Basic/dot.proverc');

    {
        my %status = (
            '503' => 'Service Unavailable',
            '502' => 'Bad Gateway',
            '500' => 'Internal Server Error',
            '504' => 'Gateway Timeout',
            '404' => 'Not Found'
        );
        while (my ($status, $status_message) = each %status) {
            $self->render_file(
                "static/$status.html",
                "Basic/static/__STATUS__.html",
                { status => $status, status_message => $status_message }
            );
        }
    }

lib/Amon2/Web.pm  view on Meta::CPAN

        ],
        [$content]
    );
}

sub res_403 {
    my ($self) = @_;
    return $self->create_simple_status_page(403, 'Forbidden');
}

sub res_404 {
    my ($self) = @_;
    return $self->create_simple_status_page(404, 'File Not Found');
}

sub res_405 {
    my ($self) = @_;
    return $self->create_simple_status_page(405, 'Method Not Allowed');
}

sub res_500 {
    my ($self) = @_;
    return $self->create_simple_status_page(500, 'Internal Server Error');

lib/Amon2/Web.pm  view on Meta::CPAN

    $c->redirect('/foo', +{bar => 3})

is same as following(if base URL is http://localhost:5000/)

    $c->create_response(302, [Location => 'http://localhost:5000/foo?bar=3'])

=item C<< $c->res_403() >>

Create new response object which has 403 status code.

=item C<< $c->res_404() >>

Create new response object which has 404 status code.

=item C<< $c->res_405() >>

Create new response object which has 405 status code.

=item C<< $c->create_simple_status_page($code, $message) >>

Create a new response object which represents specified status code.

=item C<< MyApp->to_app() : CodeRef >>

lib/Amon2/Web/Dispatcher/Lite.pm  view on Meta::CPAN

    no strict 'refs';
    *{"$caller\::dispatch"} = sub {
        my ($klass, $c) = @_;

        if (my $p = $router->match($c->request->env)) {
            return $p->{code}->($c, $p);
        } else {
            if ($router->method_not_allowed) {
                return $c->res_405();
            } else {
                return $c->res_404();
            }
        }
    };
}

1;
__END__

=encoding utf-8

lib/Amon2/Web/Dispatcher/RouterBoom.pm  view on Meta::CPAN

            if ($@) {
                if ($class->can('handle_exception')) {
                    return $class->handle_exception($c, $@);
                } else {
                    print STDERR "$env->{REQUEST_METHOD} $env->{PATH_INFO} [$env->{HTTP_USER_AGENT}]: $@";
                    return $c->res_500();
                }
            }
            return $res;
        } else {
            return $c->res_404();
        }
    };
}

1;
__END__

=head1 NAME

Amon2::Web::Dispatcher::RouterBoom - Router::Boom bindings

lib/Amon2/Web/Dispatcher/RouterSimple.pm  view on Meta::CPAN

}

sub _dispatch {
    my ($class, $c) = @_;
    my $req = $c->request;
    if (my $p = $class->match($req->env)) {
        my $action = $p->{action};
        $c->{args} = $p;
        "@{[ ref $c ]}::C::$p->{controller}"->$action($c, $p);
    } else {
        $c->res_404();
    }
}

1;
__END__

=encoding utf-8

=head1 NAME

share/flavor/Basic/t/04_csrf.t  view on Meta::CPAN

            for my $set_cookie ($res->headers->header('Set-Cookie')) {
                my ($pair) = split /;/, $set_cookie, 2;
                my ($name, $value) = split /=/, $pair, 2;
                next unless defined $name && defined $value;
                $cookies{$name} = $value;
            }
            return $res;
        };

        my $get_res = $request->(GET 'http://localhost/__csrf_probe__');
        is $get_res->code, 404, 'GET probe path returns 404';
        ok $cookies{'XSRF-TOKEN'}, 'XSRF-TOKEN cookie is issued';

        my $post_no_token = $request->(POST 'http://localhost/reset_counter');
        is $post_no_token->code, 403, 'POST without token is rejected';

        my $post_bad_token = $request->(
            POST 'http://localhost/reset_counter',
            [ 'XSRF-TOKEN' => 'invalid-token' ]
        );
        is $post_bad_token->code, 403, 'POST with invalid token is rejected';



( run in 1.679 second using v1.01-cache-2.11-cpan-39bf76dae61 )