Route::options PHP Method

options() public static method

Register a new OPTIONS route with the router.
public static options ( string $uri, Closure | array | string | null $action = null ) : Illuminate\Routing\Route
$uri string
$action Closure | array | string | null
return Illuminate\Routing\Route
        public static function options($uri, $action = null)
        {
            return \Illuminate\Routing\Router::options($uri, $action);
        }

Usage Example

Exemplo n.º 1
0
});
/*
|----------------------------------------------------------------------
| oAuth handling
|----------------------------------------------------------------------
*/
Route::post('oauth/access_token', function () {
    $bridgedRequest = OAuth2\HttpFoundationBridge\Request::createFromRequest(Request::instance());
    $bridgedResponse = new OAuth2\HttpFoundationBridge\Response();
    $bridgedResponse = App::make('oauth2')->handleTokenRequest($bridgedRequest, $bridgedResponse);
    return $bridgedResponse;
});
//Add OPTIONS routes for all defined xAPI and api routes
foreach (Route::getRoutes()->getIterator() as $route) {
    if ($route->getPrefix() === 'data/xAPI' || $route->getPrefix() === 'api/v1') {
        Route::options($route->getUri(), 'Controllers\\API\\Base@CORSOptions');
    }
}
/*
|------------------------------------------------------------------
| For routes that don't exist
|------------------------------------------------------------------
*/
App::missing(function ($exception) {
    if (Request::segment(1) == "data" || Request::segment(1) == "api") {
        $error = array('error' => true, 'message' => $exception->getMessage(), 'code' => $exception->getStatusCode());
        return Response::json($error, $exception->getStatusCode());
    } else {
        return Response::view('errors.missing', array('message' => $exception->getMessage()), 404);
    }
});
All Usage Examples Of Route::options