Created
October 21, 2014 13:53
-
-
Save matiit/3053d64edac883951be9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Http\Middleware; | |
use App; | |
use Closure; | |
use Illuminate\Contracts\Routing\Middleware; | |
class MyMiddleware implements Middleware { | |
/** | |
* Handle an incoming request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Closure $next | |
* @return mixed | |
*/ | |
public function handle($request, Closure $next) | |
{ | |
if ($request->get('xxxxxx') == 1) { | |
App::abort(); | |
} | |
return $next($request); | |
} | |
} | |
// Bind middleware | |
// App\Providers\AppServiceProvider | |
// ... | |
protected $middleware = [ | |
'auth' = 'App\Http\Middleware\AuthMiddleware', | |
'auth.basic' => 'App\Http\Middleware\BasicAuthMiddleware', | |
'csrf' => 'App\Http\Middleware\CsrfMiddleware', | |
'guest' => 'App\Http\Middleware\GuestMiddleware' | |
'mymiddleware' => 'App\Http\Middleware\MyMiddleware', | |
]; | |
// ... | |
// Controller: | |
class SomeController Extends Controller { | |
/** | |
* @Middleware("auth.basic") | |
* @Middleware("auth") | |
*/ | |
public function index() {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment