Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fsrouter/core/handler.ts

A file system based router for Deno.
Latest
import * as fsrouter from "https://deno.land/x/fsrouter@3.1.0/core/handler.ts";

Functions

fsRouter creates a standard library Handler which handles requests according to the shape of the filesystem at the given rootDir. Each file within rootDir must provide a FsHandler as its default export, which will be used to execute requests if the requested route matches the file's position in the filesystem. See docs on FsHandler.

Interfaces

A collection of options to be passed in on initialization.

Type Aliases

Every file to which routes are being served must export a function of type FsHandler as its default export. FsHandler is very similar to the standard library Handler type -- the first argument is a Request object, the second argument is of type Slugs, and the third argument is the standard library type ConnInfo. The Slugs argument is placed as the second argument instead of the third for better ergonomics. See example below for more details.

Slugs is an object of text matched from route wildcards. See FsHandler example for more details.