Handle an incoming request.

@param Request $request

@param Closure $next

@return mixed
@throws Exception
497494
public function handle(Request $request, Closure $next)
    {

        if (!$this->inPrefixes()) {
            return $next($request);
        }

        if ($this->inExcludes()) {
            return $next($request);
        }

        if (!$this->inDomains()) {
            return $next($request);
        }

        // CORS
        if (config('api.cors.cors', true)) {
            if (isset($_SERVER['HTTP_ORIGIN'])) {
                header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
            } else {
                header('Access-Control-Allow-Origin: *');
            }
            if (config('api.cors.credentials', true)) {
                header('Access-Control-Allow-Credentials: true');
            }
            header('Access-Control-Allow-Headers: Origin, X-Requested-With, No-Cache, Authorization, X-Auth-Token, Content-Type, Accept');
            header('Access-Control-Allow-Methods: GET, POST, HEAD, PUT, DELETE, PATCH, OPTIONS, TRACE');
            $age = config('api.cors.max_age', 86400);
            header("Access-Control-Max-Age: $age");
        }


        try {
            $response = $this->sendRequestThroughRouter($request);
        } catch (Exception $exception) {

            if ($this->isCompatibleWithDingo($exception)) {
                return $next($request);
            }


            $this->exception->report($exception);
            $response = $this->exception->handle($exception);

        }


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

        if ($route->hasCondition()) {
            $this->router->addWordPressBindings($route);
        }

        return $next($request);
    }
1254984
public function handle($request, Closure $next)
    {
        if ($this->auth->check() && $this->auth->viaRemember()) {
            $ip = $request->getClientIp();

            $this->updateFields($this->auth, $ip);
        }

        return $next($request);
    }
929465
public function handle($request, Closure $next)
    {
        Paginator::currentPageResolver(function () {
            return app('paginateroute')->currentPage();
        });

        return $next($request);
    }
482879
public function handle($request, Closure $next)
    {
        if (auth()->guest() || !user()->hasRoles(['client', 'member'])) {
            return $next($request);
        }
        $this->beforeSendingThroughPipeline();
        $response = $next($request);
        $this->afterSendingThroughPipeline();

        return $response;
    }
13049
public function handle(Request $request, Closure $next)
    {
        $response = $this->router->routePage($request->route()->parameter('location'));

        if ($response) {
            return $response;
        }

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

        return $response;
    }
1214694
public function handle(Request $request, Closure $next)
    {
        if (!$this->auth->check() || ($this->auth->check() && !$this->auth->user()->isAdmin)) {
            throw new HttpException(401);
        }

        return $next($request);
    }
552989
public function handle($request, Closure $next)
    {

        $request = $this->requestConverter->toCmsRequest($request);

        $request->provideCmsPath(function($request){
            $this->attachCmsPath($request);
        });

        $this->injectRequest($request);

        $this->app['events']->fire($this->requestEventName,[$request, $this]);

        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;
    }
1138999
public function handle($request, Closure $next)
    {
        if (! $this->isCorsRequest($request)) {
            return $next($request);
        }

        $this->corsProfile->setRequest($request);

        if (! $this->corsProfile->isAllowed()) {
            return $this->forbiddenResponse();
        }

        if ($this->isPreflightRequest($request)) {
            return $this->handlePreflightRequest();
        }

        $response = $next($request);

        return $this->corsProfile->addCorsHeaders($response);
    }
280947
public function handle( $request, Closure $next )
    {
        if( !$this->sentinel->check() )
        {
            return $this->denied( $request );
        }

        return $next( $request );
    }
1304649
public function handle($request, Closure $next)
    {
        $modelName = $request->route()->parameter('model');

        app()->singleton('itemconfig', function ($app) use ($modelName) {
            $configFactory = app('admin_config_factory');

            return $configFactory->make($modelName, true);
        });

        return $next($request);
    }
41077
public function handle($request, Closure $next)
    {
        config(['request.timezone' => $this->determineRequestTimezone($request)]);

        return $next($request);
    }
257664
public function handle(Request $request, \Closure $next) {
        if ($request->getMethod() == 'OPTIONS') {
            $response = new Response("", 200);
        }
        else {
            try{
                $response = $next($request);
            }catch(\Exception $e){
                $response = $this->exceptionRenderer->render($e);
            }
        }
        $this->setCorsHeaders($request, $response);
        return $response;
    }
22310
public function handle($request, Closure $next)
    {
        if ($this->sessionConfigured()) {
            $request->setLaravelSession($this->startSession($request));
        }

        return $next($request);
    }
1040215
public function handle($request, Closure $next)
    {
        $this->kernel->setClosure($next);

        return $this->middleware->handle($request);
    }