Laravel 4 bypass maintenance mode for a route

☆樱花仙子☆ 提交于 2020-01-01 11:59:26

问题


I have put my application down for maintenance using php artisan down command.

My custom maintenance page as a email input to accept the email from the user and store in my database to notify the user when the site is back up and running again.

But when I submit the form using POST, I get redirected to the maintenance mode page.

I want one particular route to bypass the maintenance mode. Is it possible?


回答1:


Okay so I found a way to go about this problem.

In my app/routes file, I have a route as follows:

// app/routes.php
Route::resource('subscriber', 'SubscriberController');

Now this will route will match any request URI for the form subscriber*

In my app/start/global.php file, I did the following inside App::down()

// app/start/global.php
App::down(function() {

    if(Request::is('subscriber*')) {
        return null;
    }

    return Response::view('maintenance', array(), 503);
})

Now only for URIs of starting with subscriber, the maintenance mode page will not be displayed.

:D



来源:https://stackoverflow.com/questions/24574052/laravel-4-bypass-maintenance-mode-for-a-route

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!