Skip to main content
Module

x/easyroute/mod.ts>serve

A simple and pragmatic approach to routing Deno web requests.
Latest
function serve
import { serve } from "https://deno.land/x/easyroute@0.2.0/mod.ts";

serve() associates REST verbs and URL paths with handler functions that execute upon invoking them as endpoints.

Examples

Example 1

serve({
	"GET /marco": () => new EasyResponse("polo"),
	"GET /hello": world,
	"GET /json": () => new EasyResponse(JSON.stringify({ message: "hello world" }), { type: "json" }),
	"GET /path/with/variables/one:string/two:boolean/three:number": pathWithVariables
});

Parameters

routes: Routes
optional
options: ServeInit = [UNSUPPORTED]