Working on middle wares.

This commit is contained in:
Taylor Otwell 2014-10-06 15:46:34 -05:00
parent 43e8c60a11
commit b8f3dd6265
6 changed files with 28 additions and 11 deletions

View File

@ -39,9 +39,9 @@ public function __construct(Authenticator $auth,
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {

View File

@ -27,9 +27,9 @@ public function __construct(Authenticator $auth)
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {

View File

@ -9,13 +9,13 @@ class CsrfMiddleware implements Middleware {
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if ($request->getSession()->token() != $request->input('_token')) if ($request->session()->token() != $request->input('_token'))
{ {
throw new TokenMismatchException; throw new TokenMismatchException;
} }

View File

@ -28,9 +28,9 @@ public function __construct(Authenticator $auth)
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {

View File

@ -28,9 +28,9 @@ public function __construct(Application $app)
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Symfony\Component\HttpFoundation\Request $request * @param \Illuminate\Http\Request $request
* @param \Closure $next * @param \Closure $next
* @return \Symfony\Component\HttpFoundation\Response * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {

View File

@ -31,4 +31,21 @@ class AppServiceProvider extends ServiceProvider {
'Illuminate\Session\Middleware\Writer', 'Illuminate\Session\Middleware\Writer',
]; ];
/**
* Build the application stack based on the provider properties.
*
* @return void
*/
public function stack()
{
$this->app->stack(function(Stack $stack, Router $router)
{
return $stack
->middleware($this->stack)->then(function($request) use ($router)
{
return $router->dispatch($request);
});
});
}
} }