2015-08-21 20 views
2

我正在嘗試使用Mojolicious單線程向用戶顯示關於服務中斷的消息。無論路線如何,我都希望顯示該信息。這是我從what's in the documentation稍微修改了一下。如何在Mojolicious中匹配所有路線?

perl -Mojo -E 'a("/" => {text => "The service is down for maintenance."})->start' daemon 

這適用於/,但沒有其他任何東西。我添加了一個星號將其變成通配符路由。

perl -Mojo -E 'a("/*" => {text => "The service is down for maintenance."})->start' daemon 

它匹配除了/以外的所有路由。有沒有辦法在單一定義中匹配所有路線?

回答

0

如何:

perl -Mojo -E 'a("/*any" => {text => "The service is down for maintenance."})->start' daemon 

我認爲它適用於所有的網址,但 '/'。

0

玩如果您創建一個名爲佔位符,與任何一個默認值,我相信你想要做什麼:

perl -Mojo -E 'a("/*x" => { text => "The service is down for maintenance.", x => ''})->start' daemon 

未必是最漂亮的代碼你會看到,但它只有幾個字符:-)