Changeset 30048 for lang/perl/HTTP-Engine-Middleware
- Timestamp:
- 02/14/09 15:55:13 (4 years ago)
- Location:
- lang/perl/HTTP-Engine-Middleware/trunk
- Files:
-
- 2 modified
-
lib/HTTP/Engine/Middleware/Static.pm (modified) (2 diffs)
-
t/200_middlewares/static.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/HTTP-Engine-Middleware/trunk/lib/HTTP/Engine/Middleware/Static.pm
r30044 r30048 7 7 use Cwd; 8 8 use MouseX::Types::Path::Class; 9 use Mouse::Util::TypeConstraints; 9 10 use File::Spec::Unix; 11 12 # corece of Regexp 13 subtype 'HTTP::Engine::Middleware::Static::Regexp' 14 => as 'RegexpRef'; 15 coerce 'HTTP::Engine::Middleware::Static::Regexp' 16 => from 'Str' => via { qr/$_/ }; 10 17 11 18 has 'regexp' => ( 12 19 is => 'ro', 13 isa => 'Regexp', 20 isa => 'HTTP::Engine::Middleware::Static::Regexp', 21 coerce => 1, 14 22 required => 1, 15 23 ); … … 162 170 # to get the your application response 163 171 172 Will you want to set config from yaml? 173 174 my $mw = HTTP::Engine::Middleware->new; 175 $mw->install( 'HTTP::Engine::Middleware::Static' => { 176 regexp => '^/(robots.txt|favicon.ico|(?:css|img)/.+|js/(?!dynamic).+)$', 177 docroot => '/path/to/htdocs/', 178 }); 179 HTTP::Engine->new( 180 interface => { 181 module => 'YourFavoriteInterfaceHere', 182 request_handler => $mw->handler( \&handler ), 183 } 184 )->run(); 185 186 # $ GET http//localhost/js/jquery.js 187 # to get the /path/to/htdocs/js/jquery.js 188 189 # $ GET http//localhost/js/dynamic-json.js 190 # to get the your application response 164 191 165 192 =head1 DESCRIPTION -
lang/perl/HTTP-Engine-Middleware/trunk/t/200_middlewares/static.t
r30044 r30048 62 62 my @config2 = ( 63 63 'HTTP::Engine::Middleware::Static' => { 64 regexp => qr{^(/(?:css|js|img)/(?!dynamic).+|/manual/.*|/robots\.txt)$},64 regexp => '(/(?:css|js|img)/(?!dynamic).+|/manual/.*|/robots\.txt)$', 65 65 docroot => Path::Class::Dir->new('t', 'htdocs')->stringify, 66 66 directory_index => 'index.html',
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)