src/Router.php
public function process(Request $request) : Response
    {
        // Try and run the next middleware
        $next = next($this->prerouteMiddleware);
        if ($next instanceof Middleware) {
            $this->log("Router: Calling Middleware: %s", get_class($next));
            $response = $next->process($request, $this);
            $this->log("Router: Leaving Middleware: %s", get_class($next));
            return $response;
        } elseif (is_string($next)) {
            $this->log("Router: Calling Middleware: %s", $next);
            $response = $this->getMiddleware($next)->process($request, $this);
            $this->log("Router: Leaving Middleware: %s", $next);
            return $response;
        } else {
            // Null byte poisoning protection
            list($uri) = explode('?', str_replace(chr(0), '', $request->server->get('REQUEST_URI')));
            $dispatch = $this->dispatcher->dispatch($request->server->get('REQUEST_METHOD'), $uri);
            switch ($dispatch[0]) {
                case Dispatcher::NOT_FOUND:
                    $this->log("Router: Route not matched");
                    throw new Exception\NotFound('Router: Route not matched');
                
                case Dispatcher::METHOD_NOT_ALLOWED:
                    $this->log("Router: Method not Allowed");
                    throw new Exception\MethodNotAllowed(
                        $dispatch[1],
                        'Router: Method not Allowed: ' . $request->getMethod()
                    );
                
                case Dispatcher::FOUND:
                    $dispatcher = unserialize($dispatch[1]);
                    $this->log(
                        "Router: Route matched: %s@%s",
                        $dispatcher->controllerClass,
                        $dispatcher->controllerMethod
                    );
                    return $dispatcher->startProcessing($this, $request, $uri, $dispatch[2]);
            }
        }
    }
public function process(Request $request) : Response
    {
        // Try and run the next middleware
        $next = next($this->prerouteMiddleware);
        if ($next instanceof Middleware) {
            $this->log("Router: Calling Middleware: %s", get_class($next));
            $response = $next->process($request, $this);
            $this->log("Router: Leaving Middleware: %s", get_class($next));
            return $response;
        } elseif (is_string($next)) {
            $this->log("Router: Calling Middleware: %s", $next);
            $response = $this->getMiddleware($next)->process($request, $this);
            $this->log("Router: Leaving Middleware: %s", $next);
            return $response;
        } else {
            // Null byte poisoning protection
            list($uri) = explode('?', str_replace(chr(0), '', $request->server->get('REQUEST_URI')));
            $dispatch = $this->dispatcher->dispatch($request->server->get('REQUEST_METHOD'), $uri);
            switch ($dispatch[0]) {
                case Dispatcher::NOT_FOUND:
                    $this->log("Router: Route not matched");
                    throw new Exception\NotFound('Router: Route not matched');
                
                case Dispatcher::METHOD_NOT_ALLOWED:
                    $this->log("Router: Method not Allowed");
                    throw new Exception\MethodNotAllowed(
                        $dispatch[1],
                        'Router: Method not Allowed: ' . $request->getMethod()
                    );
                
                case Dispatcher::FOUND:
                    $dispatcher = unserialize($dispatch[1]);
                    $this->log(
                        "Router: Route matched: %s@%s",
                        $dispatcher->controllerClass,
                        $dispatcher->controllerMethod
                    );
                    return $dispatcher->startProcessing($this, $request, $uri, $dispatch[2]);
            }
        }
    }
Process a route
Will call pre-route middleware, then match route and execute that route (more middleware + controller)

@param Request $request Request object for current process
@return Response Response to http request ready for dispatch