Skip to main content
Module

x/http_fns/map.ts>mapData

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

Create a Request handler that maps the incoming Request and first arg to a new arg, then calls the given handler with the original Request and the new argument.

Useful for mapping a request with URLPatternResult to template/component properties.

Parameters

mapper: (req: Request, data: I) => O | Promise<O>

a function that takes the Request and first arg and returns a new arg

handler: (req: Request, data: O) => Awaitable<Response | null>

the handler to call with the new arg