Under routes do not match on their own. They must have routes under them to
be the final destination of the route. If you don't have any routes under
/app, then just make it a regular ->get.

-Dan

On Sun, Mar 10, 2019 at 2:03 PM Adam Hopkins <violapirateju...@gmail.com>
wrote:

> I have an authenticated part of my app, where I want all paths under
> "/app*" to go to the same action. I thought I could do this with only one
> route, but I seem to need two:
>
> my $session_auth_route = $app->routes->under('/app' => sub ($c) {
>     return 1 if $c->is_session_authenticated;
>
>
>     $c->redirect_to('/');
>     return;
> });
>
>
> # without this, /app alone will not match
> $session_auth_route->get('/')->to(controller => 'app', action => 'index');
>
>
> # I thought this would cover /app and /app/whatever, but it only works
> when there is more after /app in the path
> $session_auth_route->get('/*')->to(controller => 'app', action => 'index'
> );
>
> Is there a better way to get this working with only one route that will
> match everything under /app and including /app?
>
> --
> 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 mojolicious+unsubscr...@googlegroups.com.
> To post to this group, send email to mojolicious@googlegroups.com.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to