Hello dear esteemed monks,
My toy framework called MVC::Neaf has crawled to 0.20 milestone. EDIT And it's got some misleading method names in it which I would like to correct.
One thing I'm struggling to grasp is how to call requested path's fragments - the part that matched the current controller and whatever follows that path. The current convention is as follows:
The overall /EDIT syntax, though still evolving, looks like follows now:
use strict; use warnings; use MVC::Neaf qw(:sugar); get + post '/some/path' => sub { my $req = shift; my $foo = $req->param( foo ); my $bar = $req->param( bar => '\w+' ) # no params w/o validation or die 404; # render a "not found" page my ($from, $to) = $req->path_info_split; $req->script_name; # '/some/path' # frobnicate my $data = frobnicate( $bar, $from .. $to ); return { result => $data, foo => $foo, }; }, default => { -view => 'TT', # JS is the default which generates JSON -template => 'some_file.tt', title => 'My mega new application', version => '0.42', }, param_regex => { foo => '\d+' }, path_info_regex => '(\d+)/(\d+)'; # Hitting /some/path would trigger roughly something like follows # (assuming the controller doesn't die/redirect/stop otherwise) # $my_template->process( 'some_file.tt', { # title => ..., # version => ..., # result => ..., # # whatever else controller returned # } ); neaf->run;
Some working examples exist in the distro.
I know everyone else is using routes of form '/foo/:bar' these days but I don't really like it (although support may be added in the end). The reason is there are a number of formats (:foo, *bar, #baz) and they still don't cover all needed cases ([0-9]+ being the most obvious one).
Now I feel like like these SCRIPT_NAME and PATH_INFO dating back into past century are awkward. My proposal is to rename this stuff completely:
This scheme looks consistent and clear to me, but maybe I'm missing something. Does that look like a syntax you'd like to try out? What would you like to be added/removed? What is causing surprise and awkwardness here?
Thank you,
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |