Calls the next middleware in the chain.
DO NOT call directly.

@param Request  $req
@param Response $res

@return Response
349488
public function nextMiddleware(Request $req, Response $res)
    {
        $middleware = $this->middleware->current();

        // base case - no middleware left
        if (!$middleware) {
            return $res;
        }

        // otherwise, call next middleware
        $this->middleware->next();

        return $middleware($req, $res, [$this, 'nextMiddleware']);
    }
745003
function(req, res, next) {
			res.set('XX-Powered-By', 'Restpress');
			req.resource = self;
			req.actionName = actionName;
			req.action = action;
			next();
		}
574136
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $isExecutingNextHandler = false;
        $next = new class($isExecutingNextHandler, $handler) implements RequestHandlerInterface {
            /**
             * @var bool
             */
            private $isExecutingNextHandler;
            /**
             * @var RequestHandlerInterface
             */
            private $nextHandler;

            public function __construct(bool &$isExecutingNextHandler, RequestHandlerInterface $realHandler)
            {
                $this->isExecutingNextHandler = &$isExecutingNextHandler;
                $this->nextHandler = $realHandler;
            }

            /**
             * Handle the request and return a response.
             */
            public function handle(ServerRequestInterface $request): ResponseInterface
            {
                $this->isExecutingNextHandler = true;
                $result = $this->nextHandler->handle($request);
                $this->isExecutingNextHandler = false;

                return $result;
            }
        };

        try {
            return $this->middleware->process($request, $next);
        } catch (\Throwable $throwable) {
            if ($isExecutingNextHandler) {
                throw $throwable;
            }

            return $handler->handle($request);
        }
    }
338581
function post (req, res, next) {
    var prop = pluralize.singular(req.params.resource)
    req.body[prop + 'Id'] = utils.toNative(req.params.id)
    req.url = '/' + req.params.nested
    next()
  }
1303500
function handler(req, res, next) {
    next = next || send

    if (pending) return pending.once('ready', function(err) {
      if (err) return next(err)
      return handler(req, res, next)
    })

    if (prevError) return next(prevError)

    res.setHeader('content-type', 'text/css')
    return next(null, buffer)

    function send(err, body) {
      if (err) return res.emit(err)
      res.end(body)
    }
  }
87077
function callbackMiddleware (req, res, next) {
  if (req.url.indexOf('callback') === -1) {
    next()
  } else if (req.url.indexOf('error') === -1) {
    res.status(200).jsonp({ created: true })
  } else {
    res.status(400).jsonp({ error: true })
  }
}
13049
public function handle(Request $request, Closure $next)
    {
        $response = $this->router->routePage($request->route()->parameter('location'));

        if ($response) {
            return $response;
        }

        return $next($request);
    }
741103
public function handle(Request $request, callable $next)
    {
        $method                     = $request->param('__ACTION__', $request->getMethod());
        $server                     = $request->server();
        $server[ 'REQUEST_METHOD' ] = $method;

        $pathInfo = $request->getPathInfo();

        $this->router->match($pathInfo, $server);

        if ( !$route = $this->router->getMatchedRoute() ) {
            throw new \Exception(
                sprintf(
                    'Could not find a route for the path info "%s"',
                    $pathInfo
                ),
                Response::HTTP_NOT_FOUND
            );
        }

        $routeParams = $this->router->getMatchedRoute()->getRouteParams();

        $request->set('__ACTION__', strtolower($method));

        foreach ($routeParams as $paramName => $paramValue) {
            if ( $paramName == 'namespace' || $paramName == 'controller' || $paramName == 'action' ) {
                $paramName = '__' . strtoupper($paramName) . '__';
            }
            $request->set($paramName, $paramValue);
        }

        $middlewares = $this->router->getMiddlewares($route->getName());

        $pipe = $this->middlewarePipe->pipe($middlewares);
        if ( $response = $pipe($request) ) {
            return $response;
        }

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

        $response->header('Turbolinks-Location', $request->fullUrl());

        return $response;
    }
1130948
public function call(Request $request, Response $response) : Response {

		return call_user_func($this->callable, $request, $response, $this->slugs);

	}
779387
public function handle($request, Closure $next)
    {
        $type = 'laravel';
        if ($this->cors->isPreflightRequest($type, $request)) {
            $this->cors->setRequest($type, $request);
            $this->cors->setResponse($type, $response = new Response());
            $this->cors->handle();

            // Set Preflight response status code.
            $response->setStatusCode(204);

            return $response;
        }

        return $next($request);
    }
685256
function clone(req, res, next) {
  var cloneFormParams = {
    _id: req.params.id,
    name: req.body.name,
    userEmail: req.body.updatedBy
  };

  logger.debug("Middleware: clone form: ", {params: cloneFormParams});

  forms.cloneForm(_.extend(req.connectionOptions, cloneFormParams), formsResultHandlers(constants.resultTypes.forms, req, next));
}
22190
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $middlewares = $this->module_service->findByInterface(MiddlewareInterface::class);

        $pipeline = $handler;

        foreach ($middlewares as $middleware) {
            $pipeline = new class($pipeline, $middleware) implements RequestHandlerInterface {
                /** @var RequestHandlerInterface */
                private $handler;

                /** @var MiddlewareInterface */
                private $middleware;

                public function __construct(RequestHandlerInterface $handler, MiddlewareInterface $middleware)
                {
                    $this->handler    = $handler;
                    $this->middleware = $middleware;
                }

                public function handle(ServerRequestInterface $request): ResponseInterface
                {
                    return $this->middleware->process($request, $this->handler);
                }
            };
        }

        return $pipeline->handle($request);
    }
42705
public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
    {
        $response = $next->handle($request);

        if (\count($this->originHosts)) {
            $response = $response->withHeader(self::ORIGIN, implode(' ', $this->originHosts));
        }

        if (\count($this->allowHeaders)) {
            $response = $response->withHeader(self::HEADERS, implode(', ', $this->allowHeaders));
        }

        if (\count($this->allowMethods)) {
            $response = $response->withHeader(self::METHODS, implode(', ', $this->allowMethods));
        }

        return $response;
    }
47298
private void handle(final Request request, final Response response, final List<Middleware> middlewares) throws Exception {
		if (middlewares.isEmpty()) {
			throw new NotFoundException();
		}
		
		Middleware current = middlewares.remove(0);
		current.handle(request, response, new MiddlewareChain() {
			@Override
			public void next() throws Exception {
				// recursive call
				handle(request, response, middlewares);
			}
		});
	}
437483
public function onRequest($req, $res)
    {
        $this->app->event->trigger('swoole.request');

        $this->resetOnRequest();

        /** @var Sandbox $sandbox */
        $sandbox = $this->app->make(Sandbox::class);
        $request = $this->prepareRequest($req);

        try {
            $sandbox->setRequest($request);

            $sandbox->init();

            $response = $sandbox->run($request);

            $this->sendResponse($sandbox, $response, $res);
        } catch (Throwable $e) {
            try {
                $exceptionResponse = $this->app
                    ->make(Handle::class)
                    ->render($request, $e);

                $this->sendResponse($sandbox, $exceptionResponse, $res);
            } catch (Throwable $e) {
                $this->logServerError($e);
            }
        } finally {
            $sandbox->clear();
        }
    }
697842
public function handle(Request $request, Closure $next)
    {
        $cors = $this->getCorsAnalysis($request);

        switch ($cors->getRequestType()) {
            case AnalysisResultInterface::TYPE_REQUEST_OUT_OF_CORS_SCOPE:
                $response = $next($request);
                break;

            case AnalysisResultInterface::TYPE_PRE_FLIGHT_REQUEST:
                $headers  = $this->getPrepareCorsHeaders($cors->getResponseHeaders());
                $response = new Response(null, Response::HTTP_OK, $headers);
                break;

            case AnalysisResultInterface::TYPE_ACTUAL_REQUEST:
                /** @var Response $response */
                $response = $next($request);
                // merge CORS headers to response
                foreach ($this->getPrepareCorsHeaders($cors->getResponseHeaders()) as $name => $value) {
                    $response->headers->set($name, $value, false);
                }
                break;

            default:
                $response = $this->getResponseOnError($cors);
                break;
        }

        return $response;
    }