Example #1
0
 /**
  * Dispatch a request.
  *
  * @param \Illuminate\Http\Request $request
  * @param string                   $version
  *
  * @return mixed
  */
 public function dispatch(Request $request, $version)
 {
     if (!isset($this->routes[$version])) {
         throw new UnknownVersionException();
     }
     $this->removeRequestMiddlewareFromApp();
     $routes = $this->routes[$version];
     $this->app->setDispatcher(new $this->dispatcher($routes->getData()));
     return $this->app->dispatch($request);
 }
 public function testUsingCustomDispatcher()
 {
     $routes = new FastRoute\RouteCollector(new FastRoute\RouteParser\Std(), new FastRoute\DataGenerator\GroupCountBased());
     $routes->addRoute('GET', '/', [function () {
         return response('Hello World');
     }]);
     $app = new Application();
     $app->setDispatcher(new FastRoute\Dispatcher\GroupCountBased($routes->getData()));
     $response = $app->handle(Request::create('/', 'GET'));
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('Hello World', $response->getContent());
 }
 /**
  * Set the FastRoute dispatcher instance.
  *
  * @param \FastRoute\Dispatcher $dispatcher
  * @return void 
  * @static 
  */
 public static function setDispatcher($dispatcher)
 {
     \Laravel\Lumen\Application::setDispatcher($dispatcher);
 }