Skip to main content
Module

x/sift/mod.ts>serve

Sift is a routing and utility library for Deno Deploy.
Latest
function serve
import { serve } from "https://deno.land/x/sift@0.6.0/mod.ts";

serve() registers "fetch" event listener and invokes the provided route handler for the route with the request as first argument and processed path params as the second.

Examples

Example 1

serve({
 "/": (request: Request) => new Response("Hello World!"),
 404: (request: Request) => new Response("not found")
})

The route handler declared for 404 will be used to serve all requests that do not have a route handler declared.

Parameters

userRoutes: Routes
optional
options: ServeInit = [UNSUPPORTED]