Example #1
0
 /**
  * Dispatch the request
  *
  * @param Request $request
  *
  * @return Response
  */
 public function __invoke(Request $request)
 {
     $route = $this->dispatcher->dispatch($request, $this->router->all());
     if ($this->closure->isSatisfiedBy($route)) {
         $response = $this->closure->dispatch($route);
     } else {
         $response = $this->controller->dispatch($route);
     }
     return $this->factory->make($response);
 }
Example #2
0
 public function test_can_check_if_action_needs_to_be_dispatched_as_closure()
 {
     $this->assertTrue($this->dispatcher->isSatisfiedBy(new Route(['GET'], '/', function () {
     })));
     $this->assertFalse($this->dispatcher->isSatisfiedBy(new Route(['GET'], '/', 'Controller@index')));
 }