class Stremio::Addon::DevKit::RouteHandler

Overview

Inspired by Kemal::RouteHandler, this Handler is not a singleton nor will it return a http-404 if a match is not made

It provides a Kemal::RouteHandler-like interface, but respects Kemals request that libraries use add_handler to inject routes, rather than adding them to the global Kemal::RouteHandler.

Included Modules

Direct Known Subclasses

Defined in:

stremio-addon-devkit/route_handler.cr

Constant Summary

CACHED_ROUTES_LIMIT = 64
HTTP_METHODS = ["get", "post", "put", "patch", "delete", "options"] of ::String

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Class Method Detail

def self.redirect(env : HTTP::Server::Context, url : String, status_code : Int32 = 302, *, body : String | Nil = nil, close : Bool = true) #

A handful of utility functions


[View source]

Instance Method Detail

def add_route(method : String, path : String, &handler : HTTP::Server::Context -> _) #

Adds a given route to routing tree. Should not be needed to call directly, use the macros below


[View source]
def call(context : HTTP::Server::Context) #

[View source]
def delete(path : String, &block : HTTP::Server::Context -> _) #

[View source]
def get(path : String, &block : HTTP::Server::Context -> _) #

[View source]
def lookup_route(verb : String, path : String) #

Looks up the route from the Radix::Tree for the first time and caches to improve performance.


[View source]
def options(path : String, &block : HTTP::Server::Context -> _) #

[View source]
def patch(path : String, &block : HTTP::Server::Context -> _) #

[View source]
def post(path : String, &block : HTTP::Server::Context -> _) #

[View source]
def put(path : String, &block : HTTP::Server::Context -> _) #

[View source]