Hi, I'm new to Mojolicious but I managed to write a functional app starting
with Mojolicious::Lite, basically some simple APIs.
When growing to Mojolicious (4.75) I noticed a strange behaviour about
routes/placeholder that I cannot understand (even after reading this
mailing list and the documentation), I'll try to explain:
With M::L
=========
I define a simple route:
<code>
get '/metricdata/:acronym/:minutes/:metric' => sub {
my $self = shift;
my $acronym=uc($self->param('acronym'));
my $minutes=$self->param('minutes');
my $metric=$self->param('metric');
my $extn = $self->stash('format');
print "#metricdata parameters: acronym: $acronym, minutes: $minutes,
metric: $metric [format: $extn]\n";
</code>
curl http://localhost:3000/metricdata/ACR0/5/queuedepth.csv
I get the correct data and on console: #metricdata parameters: acronym:
ACR0, minutes: 5, metric: queuedepth [format: csv]
I get the correct separation between metric and its format...
With Mojolicious
================
I defined an API controller and its route:
<code>
> my $r = $self->routes;
> $r->route('/metricdata/:acronym/:minutes/:metric', acronym =>
> qr/[A-Z]+\d/, minutes => qr/\d+/, metric => qr/.+/)->to('API#metricdata');
</code>
API#metricdata:
<code>
> sub metricdata {
> my $self=shift;
> my $acronym=uc($self->param('acronym'));
> my $minutes=$self->param('minutes');
> my $metric=$self->param('metric');
> my $extn=$self->stash('format');
> print "#metricdata parameters: acronym: $acronym, minutes: $minutes,
> metric: $metric [format: $extn]\n";
</code>
I get: #metricdata | parameters: acronym: ACR0, minutes: 5, metric:
queuedepth.csv [format: ]
And in the development log:
[debug] GET "/metricdata/ACR0/5/queuedepth.csv".
[debug] Routing to controller "Cruscot::API" and action "metricdata".
[debug] 204 No Content (0.004126s, 242.365/s).
So basically: with M::L I get the separation between the placeholder
"metric" and its asked type "csv" but in the full app I don't.
Currently I force format => 'csv' in the route and strip everything after
the dot in the metric variable but of course these are workarounds...
Any hints?
TIA
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/groups/opt_out.