I just create two routes:
$r->any ( '/api/v:api', [ api => qr/\d+/ ], { api => 1 } )->partial( 1 );
$r->under( '/api/v:api', [ api => qr/\d+/ ], { api => 1 } );
It seems both work same.
What is the difference under hood between them?
UPD
I have noticed that for first case (->any
) link to static files are moved to /api/v1
. This is noticeable when exception happen. mojo/debug
template tries to load static files from /api/v1/...
path and not /...
. Why?
The
under
is called before anything else. You can place authentication code inside it.It's very important that you have to place under above the routines you want to protect.