7👍
I think the Perl web framework with most Rails-like routing would be Mojolicious
The creator of Mojolicious
did write an excellent blog post called “Dispatchers for dummies” comparing the major Perl, Ruby & Python web frameworks and highlighting what he believed were improvements he made with routing on Mojolicious
.
Unfortunately above post is no longer online 🙁 Instead you have to settle for the Mojolicious::Guides::Routing
documentation. Here is a routing example from the docs:
package MyApp;
use base 'Mojolicious';
sub startup {
my $self = shift;
# Router
my $r = $self->routes;
# Route
$r->route('/welcome')->to(controller => 'foo', action => 'welcome');
}
1;
There are also other Perl frameworks which provide direct URL to action routing:
Jifty
(uses a nice routing DSL)Dancer
(Ruby Sinatra-like)Mojolicious::Lite
(ditto)Squatting
(inspired by Ruby Camping)Web::Simple
A more complete list of Perl web frameworks can be found on the Perl5 wiki
And if you are framework adverse then take a look at Plack
(also see PSGI wikipedia). This is same as Rack on Ruby and WSGI on Python.
Here is a quick and dirty example of Plack:
use 5.012;
use warnings;
my $app = sub {
my $env = shift;
given ($env->{PATH_INFO}) {
return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Baz!' ] ]
when '/hello/baz';
default {
return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ]];
}
}
}
Then use plackup above_script.psgi
and away you go.
3👍
Quite possible with Catalyst, although nobody ever seems to use it, except for internationalising the internally defined dispatch paths.
- [Django]-Custom the `on_delete` param function in Django model fields
- [Django]-Running Django 1.5 and Django 1.3 on the same server
- [Django]-Is it okay to use os.sep instead of "/" in url
- [Django]-Refactor this Python code to iterate over a container