Changeset 17398
- Timestamp:
- 08/11/08 16:07:03 (5 years ago)
- Location:
- lang/perl/HTTP-Engine/trunk/lib/HTTP
- Files:
-
- 4 modified
-
Engine.pm (modified) (3 diffs)
-
Engine/Interface/Test.pm (modified) (1 diff)
-
Engine/Request.pm (modified) (4 diffs)
-
Engine/Response.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/HTTP-Engine/trunk/lib/HTTP/Engine.pm
r17384 r17398 45 45 use Data::Dumper; 46 46 sub handle_request { 47 my $ c= shift;48 $c->res->body( Dumper($c->req) );47 my $req = shift; 48 HTTP::Engine::Response->new( body => Dumper($req) ); 49 49 } 50 50 … … 54 54 Version 0.0.x is a concept release, the internal interface is still fluid. 55 55 It is mostly based on the code of Catalyst::Engine. 56 57 =head1 COMPATIBILITY 58 59 version over 0.0.13_1 is uncompatible of version under 0.0.13_1. 60 61 useing L<HTTP::Engine::Conpat> module if you want compatibility of version under 0.0.13_1. 62 63 version over 0.0.13_1 is unsupported of context and middleware. 56 64 57 65 =head1 DESCRIPTION … … 128 136 )->run(); 129 137 130 =head1 MIDDLEWARES131 132 For all non-core middlewares (consult #codrepos first), use the HTTPEx::133 namespace. For example, if you have a plugin module named "HTTPEx::Middleware::Foo",134 you could load it as135 136 use HTTP::Engine middlewares => [ qw( +HTTPEx::Plugin::Foo ) ];137 138 =head1 METHODS139 140 =over 4141 142 =item load_middleware(middleware)143 144 =item load_middlewares(qw/ middleware middleware /)145 146 Loads the given middleware into the HTTP::Engine.147 148 =back149 150 138 =head1 CONCEPT 151 139 -
lang/perl/HTTP-Engine/trunk/lib/HTTP/Engine/Interface/Test.pm
r17379 r17398 57 57 }, 58 58 request_handler => sub { 59 my $ c= shift;60 $c->res->body( Dumper($c) );59 my $req = shift; 60 HTTP::Engine::Response->new( body => Dumper($req) ); 61 61 } 62 62 )->run(HTTP::Request->new( GET => 'http://localhost/'), \%ENV); -
lang/perl/HTTP-Engine/trunk/lib/HTTP/Engine/Request.pm
r17384 r17398 376 376 =head1 SYNOPSIS 377 377 378 $c->req 378 sub handle_request { 379 my $req = shift; 379 380 380 381 =head1 ATTRIBUTES … … 385 386 386 387 Returns the IP address of the client. 387 388 =item context389 390 Returns the HTTP::Context(internal use only)391 388 392 389 =item cookies … … 478 475 A convenient method to access $req->cookies. 479 476 480 $cookie = $ c->req->cookie('name');481 @cookies = $ c->req->cookie;477 $cookie = $req->cookie('name'); 478 @cookies = $req->cookie; 482 479 483 480 =item param 484 481 485 482 Returns GET and POST parameters with a CGI.pm-compatible param method. This 486 is an alternative method for accessing parameters in $ c->req->parameters.487 488 $value = $ c->req->param( 'foo' );489 @values = $ c->req->param( 'foo' );490 @params = $ c->req->param;483 is an alternative method for accessing parameters in $req->parameters. 484 485 $value = $req->param( 'foo' ); 486 @values = $req->param( 'foo' ); 487 @params = $req->param; 491 488 492 489 Like L<CGI>, and B<unlike> earlier versions of Catalyst, passing multiple 493 490 arguments to this method, like this: 494 491 495 $ c->req->param( 'foo', 'bar', 'gorch', 'quxx' );492 $req->param( 'foo', 'bar', 'gorch', 'quxx' ); 496 493 497 494 will set the parameter C<foo> to the multiple values C<bar>, C<gorch> and … … 508 505 A convenient method to access $req->uploads. 509 506 510 $upload = $ c->req->upload('field');511 @uploads = $ c->req->upload('field');512 @fields = $ c->req->upload;513 514 for my $upload ( $ c->req->upload('field') ) {507 $upload = $req->upload('field'); 508 @uploads = $req->upload('field'); 509 @fields = $req->upload; 510 511 for my $upload ( $req->upload('field') ) { 515 512 print $upload->filename; 516 513 } -
lang/perl/HTTP-Engine/trunk/lib/HTTP/Engine/Response.pm
r17384 r17398 80 80 =head1 SYNOPSIS 81 81 82 $c->res 82 sub handle_request { 83 my $req = shift; 84 my $res = HTTP::Engine::Response->new; 85 $res->body('foo'); 86 return $res; 87 } 83 88 84 89 =head1 ATTRIBUTES … … 99 104 references used to construct a L<CGI::Cookie> object. 100 105 101 $ c->res->cookies->{foo} = { value => '123' };106 $res->cookies->{foo} = { value => '123' }; 102 107 103 108 The keys of the hash reference on the right correspond to the L<CGI::Cookie> … … 109 114 Sets or returns the HTTP status. 110 115 111 $ c->res->status(404);116 $res->status(404); 112 117 113 118 =item headers … … 115 120 Returns an L<HTTP::Headers> object, which can be used to set headers. 116 121 117 $ c->res->headers->header( 'X-HTTP-Engine' => $HTTP::Engine::VERSION );122 $res->headers->header( 'X-HTTP-Engine' => $HTTP::Engine::VERSION ); 118 123 119 124 =item redirect … … 121 126 Causes the response to redirect to the specified URL. 122 127 123 $ c->res->redirect( 'http://slashdot.org' );124 $ c->res->redirect( 'http://slashdot.org', 307 );128 $res->redirect( 'http://slashdot.org' ); 129 $res->redirect( 'http://slashdot.org', 307 ); 125 130 126 131 =item set_http_response
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)