API REFERENCE

Request

import { getPathname, getQueryParams, getQueryParam, parseJson, parseUrlEncoded, parseFormData, parseText, parseBody, parseCookies, getCookie, } from '@rasenganjs/futon';

Standalone functions over the Web API Request — every one of them takes a Request and returns a plain value, so they work equally well inside a handler, a middleware, or a test. See Request Utilities and Cookies for usage.

URL Helpers

function getPathname(request: Request): string; function getQueryParams(request: Request): Record<string, string>; function getQueryParam(request: Request, key: string): string | null;
FunctionReturns
getPathname(request)The request's pathname (e.g. "/users/42").
getQueryParams(request)Every query parameter as a plain object.
getQueryParam(request, key)A single query parameter, or null if absent.

Body Parsers

function parseJson<T = unknown>(request: Request): Promise<T>; function parseUrlEncoded(request: Request): Promise<Record<string, string>>; function parseFormData(request: Request): Promise<FormData>; function parseText(request: Request): Promise<string>; function parseBody<T = unknown>( request: Request ): Promise<T | Record<string, string> | FormData | string>;
FunctionParses
parseJson(request)application/json bodies. Throws SyntaxError on invalid JSON.
parseUrlEncoded(request)application/x-www-form-urlencoded bodies.
parseFormData(request)multipart/form-data bodies — returns the native FormData.
parseText(request)Any body as plain text.
parseBody(request)Auto-detects Content-Type and delegates to one of the above.

parseBody()'s detection order: application/jsonapplication/x-www-form-urlencodedmultipart/form-data → falls back to text for everything else (including text/*).

Cookies

function parseCookies(request: Request): Record<string, string>; function getCookie(request: Request, name: string): string | undefined;

parseCookies() reads the Cookie header into a plain key-value map (handling multiple cookies and URL-decoding). getCookie() is a shorthand for a single name. For setting cookies on the way out, see setCookie() on the Response reference.

Context
Response