Dancer::Core::Server::PSGI - TODO
version 2.0000_01
sub start { my $self = shift; my $app = $self->psgi_app(); foreach my $setting (qw/plack_middlewares plack_middlewares_map/) { if (Dancer::Config::setting($setting)) { my $method = 'apply_'.$setting; $app = $self->$method($app); } } return $app; } sub apply_plack_middlewares_map { my ($self, $app) = @_; my $mw_map = Dancer::Config::setting('plack_middlewares_map'); foreach my $req (qw(Plack::App::URLMap Plack::Builder)) { croak "$req is needed to use apply_plack_middlewares_map" unless Dancer::ModuleLoader->load($req); } my $urlmap = Plack::App::URLMap->new; while ( my ( $path, $mw ) = each %$mw_map ) { my $builder = Plack::Builder->new(); map { $builder->add_middleware(@$_) } @$mw; $urlmap->map( $path => $builder->to_app($app) ); } $urlmap->map('/' => $app) unless $mw_map->{'/'}; return $urlmap->to_app; } sub apply_plack_middlewares { my ($self, $app) = @_; my $middlewares = Dancer::Config::setting('plack_middlewares'); croak "Plack::Builder is needed for middlewares support" unless Dancer::ModuleLoader->load('Plack::Builder'); my $builder = Plack::Builder->new(); ref $middlewares eq "ARRAY" or croak "'plack_middlewares' setting must be an ArrayRef"; map { Dancer::Logger::core "add middleware " . $_->[0]; $builder->add_middleware(@$_) } @$middlewares; $app = $builder->to_app($app); return $app; } sub init_request_headers { my ($self, $env) = @_; my $plack = Plack::Request->new($env); Dancer::SharedData->headers($plack->headers); }
This is a server implementation for PSGI. It contains all the code to handle a PSGI request.
The server's name: PSGI.
Starts the server.
Dancer Core Developers
This software is copyright (c) 2012 by Alexis Sukrieh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Dancer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer
CPAN shell
perl -MCPAN -e shell install Dancer
For more information on module installation, please visit the detailed CPAN module installation guide.