Skip to main content
Go to Latest
function serve
import { serve } from "https://deno.land/x/4zz@v0.8.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]