Skip to main content
Module

x/composium/mod.ts>createHandler

Powered by functional composition and the URL Pattern API, composium has become the most flexible routing framework in the world.
Go to Latest
function createHandler
Re-export
import { createHandler } from "https://deno.land/x/composium@v0.1.1/mod.ts";

A curried function which takes a Context class, tryMiddlewares, catchMiddlewares and finallyMiddlewares and returns a Deno.ServeHandler which can be passed to Deno.serve. It also handles the HTTP method HEAD appropriately, sets the X-Response-Time header and logs to the console by default. Optionally you can enable the logger or pass an initial state object.

const handler = createHandler(Ctx)(tryMiddlewares)(catchMiddlewares)(finallyMiddlewares)
Deno.serve(handler);

Parameters

Context: new (
request: Request,
state?: S,
) => C
optional
unnamed 1: ServerHandlerOptions<S> = [UNSUPPORTED]