Returns pre-configured OPTIONS endpoint

@param $path
@param string $handlerMethod

@return ApiEndpoint
173326
public static function options($path, $handlerMethod = null)
    {
        return self::factory($path, HttpMethods::OPTIONS, $handlerMethod);
    }
127276
public static function getHandlerByPath($path)
    {
        $result = null;
        $path   = self::prepareRoute('/'.trim($path, " /"));

        foreach (static::$routes as $key => $handler) {
            $matches = [];
            if (preg_match('#'.$key.'$#i', $path, $matches)) {
                foreach ($matches as $key => $val) {
                    if (!is_numeric($key)) {
                        $_GET[$key] = $val;
                    }
                }
                $result = $handler[1];
                break;
            }
        }
        return $result;
    }
762115
public function api($path, array $parameters = array(), $method = 'GET')
    {
        return $this->getRequest()->api($path, $method, $parameters);
    }
964575
public function post(string $path, $handler)
  {
    return $this->request($path, Request::HTTP_POST, $handler);
  }
1369356
public Javalin post(@NotNull String path, @NotNull Handler handler) {
        return addHandler(HandlerType.POST, path, handler);
    }
1200980
public function options($path, $handler, $info = null)
    {
        $this->addRoute(["OPTIONS"], null, $path, $handler, $info);
    }
228162
public Javalin get(@NotNull String path, @NotNull Handler handler, @NotNull Set<Role> permittedRoles) {
        return addHandler(HandlerType.GET, path, handler, permittedRoles);
    }
871167
public function createHandler(string $path, array $info): array
    {
        $handler = $info['handler'];
        $matches = $info['matches'] ?? [];

        // is a \Closure or a callable object
        if (\is_object($handler)) {
            return [$handler, $matches];
        }

        // is array ['controller', 'action']
        if (\is_array($handler)) {
            $segments = $handler;
        } elseif (\is_string($handler)) {
            // e.g `Controllers\Home@index` Or only `Controllers\Home`
            $segments = explode('@', trim($handler));
        } else {
            App::error('Invalid route handler for URI: ' . $path);
            throw new \InvalidArgumentException('Invalid route handler for URI: ' . $path);
        }

        $action    = '';
        $className = $segments[0];
        if (isset($segments[1])) {
            // Already assign action
            $action = $segments[1];
        } elseif (isset($matches[0])) {
            // use dynamic action
            $action = array_shift($matches);
        }

        $action     = HandlerMapping::convertNodeStr($action);
        $controller = App::getBean($className);
        $handler    = [$controller, $action];

        // Set Controller and Action info to Request Context
        RequestContext::setContextData([
            'controllerClass'  => $className,
            'controllerAction' => $action ?: 'index',
        ]);

        return [$handler, $matches];
    }
328200
public Javalin addHandler(@NotNull HandlerType httpMethod, @NotNull String path, @NotNull Handler handler) {
        return addHandler(httpMethod, path, handler, new HashSet<>()); // no roles set for this route (open to everyone with default access manager)
    }
1232739
public function patch(string $path, $handler)
  {
    return $this->request($path, Request::HTTP_PATCH, $handler);
  }
555011
public static void get(@NotNull String path, @NotNull Handler handler) {
        staticInstance().get(prefixPath(path), handler);
    }
1078196
protected function dispatchRouter($method, $path)
    {
        $resolver   = $this->make('Glue\Router\RouterResolver');
        $dispatcher = new Dispatcher($this->router->getData(), $resolver);

        $httpCode = Response::HTTP_OK;
        $allow    = null;

        try {

            $response = $dispatcher->dispatch($method, $path);
            if ($response instanceof Response) {
                $httpCode = $response->getStatusCode();
            }

        } catch(HttpRouteNotFoundException $e) {

            $response = $this->router->resolveErrorHandler(Response::HTTP_NOT_FOUND);
            $httpCode = Response::HTTP_NOT_FOUND;

        } catch(HttpMethodNotAllowedException $e) {

            $response = $this->router->resolveErrorHandler(Response::HTTP_METHOD_NOT_ALLOWED);
            $httpCode = Response::HTTP_METHOD_NOT_ALLOWED;
            if (strpos($e->getMessage(), 'Allow:') === 0) {
                // We got an Allow-message as exception message.
                // Save it so we can add it to the response header
                $allow = trim(explode(':', $e->getMessage())[1]);
            }

        } catch(\Exception $e) {

            if ($this->bound('Psr\Log\LoggerInterface')) {
                $this->make('Psr\Log\LoggerInterface')
                    ->critical($e->getMessage(), [__METHOD__]);
            }

            throw $e;

        }

        if (!$response instanceof Response) {
            $response = new Response((string) $response);
            $response->setStatusCode($httpCode);
        }

        if ($allow) {
            $response->headers->set('Allow', $allow);
        }

        return $response;
    }
909010
public function get($path, $handler, $info = null)
    {
        $this->addRoute(["GET"], null, $path, $handler, $info);
    }
978476
public function post($path, callable $handler): RouterInterface
    {
        $ruler = $this->createRuler('POST', $path);
        return $this->addRuler($ruler, $handler);
    }
988816
public static function head($path, $handlerMethod = null)
    {
        return self::factory($path, HttpMethods::HEAD, $handlerMethod);
    }
36330
public static function options($path, $callback)
    {
        self::instance()->addRoute('OPTIONS', $path, self::callback($callback));
    }
297730
public function get(string $path, $handler, array $pathParams = [], array $opts = []): Route
    {
        return $this->add('GET', $path, $handler, $pathParams, $opts);
        // return $this->map(['GET', 'HEAD'], $path, $handler, $pathParams, $opts);
    }