class Stremio::Addon::DevKit::RouteHandler
- Stremio::Addon::DevKit::RouteHandler
- Reference
- Object
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
- HTTP::Handler
Direct Known Subclasses
Defined in:
stremio-addon-devkit/route_handler.crConstant Summary
-
CACHED_ROUTES_LIMIT =
64
-
HTTP_METHODS =
["get", "post", "put", "patch", "delete", "options"] of ::String
Constructors
Class Method Summary
-
.redirect(env : HTTP::Server::Context, url : String, status_code : Int32 = 302, *, body : String | Nil = nil, close : Bool = true)
A handful of utility functions
Instance Method Summary
-
#add_route(method : String, path : String, &handler : HTTP::Server::Context -> _)
Adds a given route to routing tree.
- #call(context : HTTP::Server::Context)
- #delete(path : String, &block : HTTP::Server::Context -> _)
- #get(path : String, &block : HTTP::Server::Context -> _)
-
#lookup_route(verb : String, path : String)
Looks up the route from the Radix::Tree for the first time and caches to improve performance.
- #options(path : String, &block : HTTP::Server::Context -> _)
- #patch(path : String, &block : HTTP::Server::Context -> _)
- #post(path : String, &block : HTTP::Server::Context -> _)
- #put(path : String, &block : HTTP::Server::Context -> _)
Constructor Detail
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
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
def lookup_route(verb : String, path : String)
#
Looks up the route from the Radix::Tree for the first time and caches to improve performance.