So that makes sense that under routes need to have routes under them to be 
the final destination. I guess I thought that

$session_auth_route->get('/*')->to(controller => 'app', action => 'index');

Would cover both /app/ and /app/*.

I tried what I think you meant:


$session_auth_route->get()->to(controller => 'app', action => 'index');


And that only seemed to match /app, but nothing after /app/.

On Sunday, March 10, 2019 at 1:42:00 PM UTC-5, Dan Book wrote:
>
> 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 <[email protected] 
> <javascript:>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to