sub (/user/*) { $self->users->get($_[1]) },
}
-An alternative to using prototypes to declare a match specification for a given
-route is to provide a L<Dancer>-like key-value list:
-
- sub dispatch_request {
- my $self = shift;
- (
- '.html' => sub { response_filter { $self->render_zoom($_[0]) } },
- '/user/*' => sub { $self->users->get($_[1]) }<
- )
- }
-
-This can be useful in situations where you are generating a dispatch table
-programmatically, where setting a subroutine's protoype is difficult.
-
to render a user object to HTML, if there is an incoming URL such as:
http://myweb.org/user/111.html
=head2 Web::Simple match specifications
+Even though the following examples all use subroutine prototypes, an
+alternative to declare a match specification for a given route is to provide a
+L<Dancer>-like key-value list:
+
+ sub dispatch_request {
+ my $self = shift;
+ (
+ '.html' => sub { ... },
+ 'GET + /user/*' => sub { ... },
+ ## equivalent to:
+ # sub (.html) { ... },
+ # sub (GET + /user/*) { ... },
+ )
+ }
+
+This can be useful in situations where you are generating a dispatch table
+programmatically, where setting a subroutine's protoype is difficult.
+
=head3 Method matches
sub (GET) {