From: John Napiorkowski Date: Mon, 29 Nov 2010 19:31:05 +0000 (-0500) Subject: corrected filter example X-Git-Tag: v0.005~17 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=6af22ff2e97e0ec01c470fd86b1f9d98c387f147 corrected filter example --- diff --git a/lib/Web/Simple.pm b/lib/Web/Simple.pm index b95f36c..134e4a0 100644 --- a/lib/Web/Simple.pm +++ b/lib/Web/Simple.pm @@ -232,22 +232,38 @@ will have its ->to_app method called and be used as a dispatcher: A Plack::Middleware object will be used as a filter for the rest of the dispatch being returned into: + ## responds to /admin/track_usage AND /admin/delete_accounts + sub dispatch_request { my $self = shift; - ... - sub (/admin) { Plack::Middleware::Session->new(...) }, - ... # dispatchers needing a session go here + sub (/admin/**) { + Plack::Middleware::Session->new(%opts); + }, + sub (/admin/track_usage) { + ## something that needs a session + }, + sub (/admin/delete_accounts) { + ## something else that needs a session + }, } Note that this is for the dispatch being -returned- to, so if you want to provide it inline you need to do: + ## ALSO responds to /admin/track_usage AND /admin/delete_accounts + sub dispatch_request { my $self = shift; - ... sub (/admin/...) { - sub { Plack::Middleware::Session->new(...) }, - ... # dispatchers under /admin + sub { + Plack::Middleware::Session->new(%opts); + }, + sub (/track_usage) { + ## something that needs a session + }, + sub (/delete_accounts) { + ## something else that needs a session + }, } }