Orno\Route\Dispatcher::handleRestfulStrategy PHP Method

handleRestfulStrategy() protected method

Handles response to Restful Strategy based routes
protected handleRestfulStrategy ( string | array | Closure $controller, array $vars = [] ) : Orno\Http\ResponseInterface
$controller string | array | Closure
$vars array
return Orno\Http\ResponseInterface
    protected function handleRestfulStrategy($controller, array $vars = [])
    {
        try {
            $response = $this->invokeController($controller, [$this->container->get('Orno\\Http\\Request'), $vars]);
            if ($response instanceof JsonResponse) {
                return $response;
            }
            if (is_array($response) || $response instanceof \ArrayObject) {
                return new JsonResponse($response);
            }
            throw new \RuntimeException('Your controller action must return a valid response for the Restful Strategy. ' . 'Acceptable responses are of type: [Array], [ArrayObject] and [Orno\\Http\\JsonResponse]');
        } catch (HttpException $e) {
            return $e->getJsonResponse();
        }
    }