@param Request  $request
@param callable $next

@return Response
169805
public function handle(Request $request, callable $next)
    {
        set_error_handler(
            function ($errorNumber, $errorString) {
                throw new \Exception($errorString, $errorNumber);
            }
        );

        try {
            $response = $next($request);

            if (!$response instanceof Response) {
                return new Response(
                    $this->get500(),
                    Response::HTTP_INTERNAL_SERVER_ERROR
                );
            }

            return $response;

        } catch (\Exception $exception) {
            switch ($exception->getCode()) {
                case Response::HTTP_NOT_FOUND:
                    return new Response(
                        $this->get404(),
                        Response::HTTP_NOT_FOUND
                    );
                default:
                    return new Response(
                        $this->get500(),
                        Response::HTTP_INTERNAL_SERVER_ERROR
                    );
            }
        }
    }
217595
public function handle($request, Closure $next)
    {
        $this->app->setLocale($this->getCurrentLocale($request));

        return $next($request);
    }
1257827
public function handle(Request $request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            }

            return redirect()->guest(\Flare::adminUrl('login'));
        }

        return $next($request);
    }
995406
public function handle($request, Closure $next)
    {
        if ( ! $this->auth->check()) {
            return cms_api()->response('Unauthorized.', 401);
        }

        return $next($request);
    }
400382
public function process(Request $request, callable $next)
    {
        if (Auth::check()) {
            return $next($request);
        }

        return redirect($this->redirectTo());
    }
889151
public function handle($request, Closure $next)
    {
        $modelName = $request->route()->parameter('model');
        if (! empty($modelName)) {
            $modelInst = CrudModel::createInstance($modelName);
            if (! $modelInst->checkAcl()) {
                if ($request->ajax() || $request->wantsJson()) {
                    return response('Unauthorized.', 401);
                } else {
                    return redirect()->guest('login');
                }
            }
        }

        return $next($request);
    }
166804
public function handle(Request $request, Closure $next)
    {
        $request->attributes->add(['responsecache.doNotCache' => true]);

        return $next($request);
    }
1253502
public function handle(Request $request, Closure $next)
    {
        /** @var Response $response */
        $response = $request->isXmlHttpRequest() === true ? $next($request) : $this->createForbiddenResponse();

        return $response;
    }
234989
public function handle($request, Closure $next)
    {
        $response = $next($request);

        if (!in_array($response->getStatusCode(), config('maxfactor-support.enforceDomainsStatusCodes'))) {
            return $response;
        }

        return $this->validDomain($request, $response);
    }
1231658
public function handle($request, Closure $next)
    {
        $this->authorizer->setRequest($request);

        $this->authorizer->checkAuthCodeRequest();

        return $next($request);
    }
341479
public function handle( $request, Closure $next )
	{
		$response = $next( $request );

		foreach ( $this->cookies->getQueuedCookies() as $cookie )
			$response->headers->setCookie( $cookie );

		return $response;
	}
776169
public function handle($request, Closure $next)
    {
        $route = $request->route();

        $this->router->substituteBindings($route);

        $this->substituteImplicitBindings($route);

        return $next($request);
    }
1059794
public function handle($request, Closure $next)
    {
        $response = $next($request);

        if ($this->isAResponseObject($response) && $this->isAnHtmlResponse($response)) {
            $output = $response->getContent();
            $minified = $this->html->render($output);
            $response->setContent($minified);
        }

        return $response;
    }
1129004
public function handleRequest(RequestInterface $request, callable $next, callable $first)
    {
        return $next($request)->then(function (ResponseInterface $response) {
            $status = $response->getStatusCode();

            if ($status >= 400 && $status < 600) {
                self::handleError($status, self::getMessage($response) ?: $response->getReasonPhrase());
            }

            return $response;
        });
    }
774439
public function process(Request $request, callable $next)
    {
        foreach ($this->preventOn() as $url) {
            if ($request->is($url)) {
                return $next($request);
            }
        }

        if ($request->isAjax()) {
            if ($request->getHeader('x-csrf-token') === session('_token')) {
                return $next($request);
            }

            response()->status(401);

            return response()->send('unauthorize.');
        }

        if ($request->get('_token') == $request->session()->get('_token')) {
            return $next($request);
        }

        throw new TokenMismatch('Token Mismatch');
    }
294911
protected function handleRequest(callable $next)
    {
        $this->route($this->request);
        return $next($this->request, $this->response);
    }
1102386
public function handleRequest(RequestInterface $request, callable $next, callable $first)
    {
        return $next($request)->then(function (ResponseInterface $response) use ($request) {
            return $this->decodeResponse($response, $request);
        }, function (Exception $e) use ($request): void {
            if ($e instanceof ApiException) {
                throw $e;
            }
            if ($e instanceof HttpException || in_array(HttpException::class, class_parents($e))) {
                $this->decodeResponse($e->getResponse(), $request);
            } elseif ($e instanceof RequestException || in_array(RequestException::class, class_parents($e))) {
                throw new ApiRequestException($request, $e->getMessage(), $e->getCode(), $e);
            }

            throw new ApiException($e->getMessage(), $e->getCode(), $e);
        });
    }