src/Application.php
public function handleRequest(Request $req)
    {
        // set host name from request if not already set
        $config = $this['config'];
        if (!$config->get('app.hostname')) {
            $config->set('app.hostname', $req->host());
        }

        $res = new Response();
        try {
            // determine route by dispatching to router
            $routeInfo = $this['router']->dispatch($req->method(), $req->path());
            $this['routeInfo'] = $routeInfo;

            // set any route arguments on the request
            if (isset($routeInfo[2])) {
                $req->setParams($routeInfo[2]);
            }

            // the dispatch middleware is the final step
            $dispatch = new DispatchMiddleware();
            $dispatch->setApp($this);
            $this->middleware($dispatch);

            // the request is handled by returning the response
            // generated by the middleware chain
            return $this->runMiddleware($req, $res);
        } catch (\Exception $e) {
            return $this['exception_handler']($req, $res, $e);
        } catch (\Error $e) {
            return $this['php_error_handler']($req, $res, $e);
        }
    }
public function handleRequest(Request $req)
    {
        // set host name from request if not already set
        $config = $this['config'];
        if (!$config->get('app.hostname')) {
            $config->set('app.hostname', $req->host());
        }

        $res = new Response();
        try {
            // determine route by dispatching to router
            $routeInfo = $this['router']->dispatch($req->method(), $req->path());
            $this['routeInfo'] = $routeInfo;

            // set any route arguments on the request
            if (isset($routeInfo[2])) {
                $req->setParams($routeInfo[2]);
            }

            // the dispatch middleware is the final step
            $dispatch = new DispatchMiddleware();
            $dispatch->setApp($this);
            $this->middleware($dispatch);

            // the request is handled by returning the response
            // generated by the middleware chain
            return $this->runMiddleware($req, $res);
        } catch (\Exception $e) {
            return $this['exception_handler']($req, $res, $e);
        } catch (\Error $e) {
            return $this['php_error_handler']($req, $res, $e);
        }
    }
public function handleRequest ( Request $ req ) { // set host name from request if not already set $ config = $ this [ 'config' ] ; if ( ! $ config -> get ( 'app.hostname' ) ) { $ config -> set ( 'app.hostname' , $ req -> host ( ) ) ; } $ res = new Response ( ) ; try { // determine route by dispatching to router $ routeInfo = $ this [ 'router' ] -> dispatch ( $ req -> method ( ) , $ req -> path ( ) ) ; $ this [ 'routeInfo' ] = $ routeInfo ; // set any route arguments on the request if ( isset ( $ routeInfo [ 2 ] ) ) { $ req -> setParams ( $ routeInfo [ 2 ] ) ; } // the dispatch middleware is the final step $ dispatch = new DispatchMiddleware ( ) ; $ dispatch -> setApp ( $ this ) ; $ this -> middleware ( $ dispatch ) ; // the request is handled by returning the response // generated by the middleware chain return $ this -> runMiddleware ( $ req , $ res ) ; } catch ( \ Exception $ e ) { return $ this [ 'exception_handler' ] ( $ req , $ res , $ e ) ; } catch ( \ Error $ e ) { return $ this [ 'php_error_handler' ] ( $ req , $ res , $ e ) ; } }
Builds a response to an incoming request by routing
it through the application.

@param Request $req

@return Response
Builds a response to an incoming request by routing it through the application .