-
-
20 May 2013 12:32:44 UTC
- Distribution: Mojolicious-Plugin-Subdispatch
- Module version: 0.04
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (2502 / 0 / 1)
- Kwalitee
Bus factor: 1- 96.30% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (3.81KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Mojolicious
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Mojolicious::Plugin::Subdispatch - create requests to your Mojolicious actions
SYNOPSIS
plugin 'Subdispatch'; [web app stuff...] my $html = app->subdispatch->get('route_name', foo => 'bar')->body;
DESCRIPTION
This Mojolicious plugin creates a `subdispatch` helper, which helps you creating a request for your actions, and returns the response object with your fully rendered HTML content.
The interface has some similarities to Mojo::UserAgent: just use your request method (DELETE, GET, HEAD, POST, PUT) as the method name and pass the same arguments as you would do for `url_for`:
To build a post request with data, append the data hash at the end:
my $res = app->subdispatch->post('route', foo => 'bar', {with => 'data'});
If you want to access the transaction object around the response, use the subdispatch helper with arguments like this:
my $tx = app->subdispatch(GET => 'route', foo => 'bar'); my $tx = app->subdispatch(POST => 'route', foo => 'bar', {with => 'data'});
For some reasons, it seamed important to me to be able to set the base url of the resulting requests, so this is possible via
plugin 'Subdispatch', base_url => 'http://example.org';
This is an early version and may change without warning. I'll use it to create static HTML pages from a Mojolicious blog, but if you find another good way to use it, please let me know!
REPOSITORY AND ISSUE TRACKING
This plugin lives in github: http://github.com/memowe/mojolicious-plugin-subdispatch. You're welcome to use github's issue tracker to report bugs or discuss the code: http://github.com/memowe/mojolicious-plugin-subdispatch/issues
AUTHOR AND LICENSE
Copyright Mirko Westermeier <mail@memowe.de>
Licensed under the same terms as Perl itself.
Module Install Instructions
To install Mojolicious::Plugin::Subdispatch, copy and paste the appropriate command in to your terminal.
cpanm Mojolicious::Plugin::Subdispatch
perl -MCPAN -e shell install Mojolicious::Plugin::Subdispatch
For more information on module installation, please visit the detailed CPAN module installation guide.