Skip to main content
Module

x/http_fns/fallback.ts>withFallback

A bunch of functions for building HTTP servers
Go to Latest
function withFallback
import { withFallback } from "https://deno.land/x/http_fns@v0.0.27/fallback.ts";

Create a Request handler that guarantees a Response, by calling a fallback handler if the given handler skips.

Usually used to wrap the top level handler, so that a Not Found is returned once all routes have been exhausted.

Type Parameters

A extends unknown[]

Parameters

handler: (request: Request, ...args: A) => Awaitable<Response | null>

the handler to call first, which may or may not return a Response

optional
fallback: (request: Request, ...args: A) => Awaitable<Response> = [UNSUPPORTED]

the handler called if the above handle doesn't return a Response, this optional and defaults to a Not Found response