perl - How to add and remove routes dynamically in Mojolicious? -


i trying put maintenance page in mojolicious app of users shown whenever file or db entry present on server.

i know can check file or entry on startup , if there add in 'catch all' route. i'm not sure how dynamically? don't want have restart backend whenever want go maintenance.

is there way add , remove routes hook? example use before dispatch hook monitor file/db entry , if exists modify routes?

i tried didn't seem able access routes hooked function, in startup function.

thank you.

the router dynamic until first request has been served, after that, router cannot change routes (source). said, can not declare route , prohibit access until condition exists?

#!/usr/bin/env perl  use mojolicious::lite;  '/' => sub { shift->render( text => 'hello world' ) };  under sub {    unless (-e 'myfile') {     shift->render_not_found;     return 0;   }   return 1; };  '/protected' => sub { shift->render( text => 'i safe' ) };  app->start; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -