From 811c7f969dba4962943550c0b74e5ad179860683 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 11 Jan 2011 13:51:56 -0600 Subject: backend docs --- lib/Plack/Client/Backend/http.pm | 31 +++++++++++++++++++++ lib/Plack/Client/Backend/psgi_local.pm | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) diff --git a/lib/Plack/Client/Backend/http.pm b/lib/Plack/Client/Backend/http.pm index f57ee1f..e443385 100644 --- a/lib/Plack/Client/Backend/http.pm +++ b/lib/Plack/Client/Backend/http.pm @@ -1,9 +1,33 @@ package Plack::Client::Backend::http; use strict; use warnings; +# ABSTRACT: backend for handling HTTP requests use Plack::App::Proxy; +=head1 SYNOPSIS + + Plack::Client->new( + 'http' => {}, + ); + + Plack::Client->new( + 'http' => Plack::Client::Backend::http->new, + ); + +=head1 DESCRIPTION + +This backend implements HTTP requests. The current implementation uses +L to make the request. + +=cut + +=method new + +Constructor. Takes no arguments. + +=cut + sub new { my $class = shift; my %params = @_; @@ -15,6 +39,13 @@ sub new { sub _proxy { shift->{proxy} } +=method app_from_request + +Takes a L object, and returns an app which will retrieve the +HTTP resource. + +=cut + sub app_from_request { my $self = shift; my ($req) = @_; diff --git a/lib/Plack/Client/Backend/psgi_local.pm b/lib/Plack/Client/Backend/psgi_local.pm index 0131d02..68f6eff 100644 --- a/lib/Plack/Client/Backend/psgi_local.pm +++ b/lib/Plack/Client/Backend/psgi_local.pm @@ -1,10 +1,45 @@ package Plack::Client::Backend::psgi_local; use strict; use warnings; +# ABSTRACT: backend for handling local app requests use Carp; use Plack::Middleware::ContentLength; +=head1 SYNOPSIS + + Plack::Client->new( + 'psgi-local' => { + apps => { myapp => sub { ... } }, + }, + ); + + Plack::Client->new( + 'psgi-local' => Plack::Client::Backend::psgi_local->new( + apps => { myapp => sub { ... } }, + ), + ); + +=head1 DESCRIPTION + +This backend implements requests made against local PSGI apps. + +=cut + +=method new + +Constructor. Takes a hash of arguments, with these keys being valid: + +=over 4 + +=item apps + +A mapping of local app names to PSGI app coderefs. + +=back + +=cut + sub new { my $class = shift; my %params = @_; @@ -19,12 +54,26 @@ sub new { sub _apps { shift->{apps} } +=method app_for + +Returns the PSGI app coderef for the given app name. + +=cut + sub app_for { my $self = shift; my ($for) = @_; return $self->_apps->{$for}; } +=method app_from_request + +Takes a L object, and returns the app corresponding to the app +corresponding to the app name given in the C section of the given +URL. + +=cut + sub app_from_request { my $self = shift; my ($req) = @_; -- cgit v1.2.3-54-g00ecf