/**
  * Dispatches the specified request.
  * The optional $services parameter is passed to the constructor of handlers
  * specified in the Object::Method format.
  * @param Request          $request
  * @param ServiceContainer $services
  * @return Response
  */
 public function dispatch(Request $request, ServiceContainer $services = null)
 {
     $route = $this->router->match($request->uri(), $request->method());
     // if we have a URI prefix specified in the route then add it to the stack
     if ($prefix = isset($route['extra']['prefix'])) {
         // we can keep adding to URI prefix to allow more than one layer of delegation
         $request->pushUriPrefix($route['extra']['prefix']);
     }
     // pass through extra info about the route
     $request->extra($route['extra']);
     // make sure we have a callable handler
     $handler = $this->makeHandler($route['handler'], $services);
     // prepend the request to the parameter array
     array_unshift($route['parameters'], $request);
     $response = $this->beforeDispatch($request, $route);
     // execute the handler if we don't already have a response
     if (!$response) {
         $response = call_user_func_array($handler, $route['parameters']);
     }
     $this->afterDispatch($request, $route, $response);
     // remove the URI prefix from earlier as that application has dealt with request
     // and 'this' layer may well need to do further processing
     if ($prefix) {
         $request->popUriPrefix();
     }
     return $response;
 }
 public function dispatch(Request $request)
 {
     $request->setUriPrefix($this->services['config']->get('paths.web'));
     return parent::dispatch($request, $this->services);
 }