package Web::Simple;
use strictures 1;
-use 5.008;
use warnings::illegalproto ();
use Moo ();
use Web::Dispatch::Wrapper ();
-our $VERSION = '0.020';
+our $VERSION = '0.028';
sub import {
my ($class, $app_package) = @_;
my $self = shift;
(
'.html' => sub { response_filter { $self->render_zoom($_[0]) } },
- '/user/*' => sub { $self->users->get($_[1]) }<
+ '/user/*' => sub { $self->users->get($_[1]) },
+ 'POST + %*' => 'handle_post',
)
}
This can be useful in situations where you are generating a dispatch table
-programmatically, where setting a subroutines protoype is difficult.
+programmatically, where setting a subroutines protoype is difficult. Note that
+in the example above, C<handle_post> is a method that would be called.
to render a user object to HTML, if there is an incoming URL such as:
the C<response_filter> we defined, after which the return is converted to a
true html response.
-However, two types of object are treated specially - a C<Plack::Component> object
+However, two types of objects are treated specially - a C<Plack::Component> object
will have its C<to_app> method called and be used as a dispatcher:
sub dispatch_request {
sub (?page=&order_by~) {
my ($self, $page, $order_by) = @_;
return unless $page =~ /^\d+$/;
- $page ||= 'id';
+ $order_by ||= 'id';
response_filter {
- $_[1]->search_rs({}, $p);
+ $_[1]->search_rs({}, { page => $page, order_by => $order_by });
}
}
Robert Sedlacek (phaylon) <r.sedlacek@shadowcat.co.uk>
+Hakim Cassimally (osfameron) <osfameron@cpan.org>
+
+Karen Etheridge (ether) <ether@cpan.org>
+
=head1 COPYRIGHT
Copyright (c) 2011 the Web::Simple L</AUTHOR> and L</CONTRIBUTORS>