Skip to main content
Module

x/momentum/static-files/deps.ts>ContextAccessor

Momentum is an open-source framework for building server-side Deno applications in TypeScript. It provides the paradigms and design patterns to guide developers to create robust, scalable, and enterprise-grade applications.
Latest
class ContextAccessor
Re-export
import { ContextAccessor } from "https://deno.land/x/momentum@v0.8.2/static-files/deps.ts";

Wraps the platform specific context object with a standard interface

Constructors

new
ContextAccessor(context: unknown, platform: ServerPlatform)

Methods

getBody(): Promise<unknown>

Get the request body

getBody(name: string | undefined): Promise<unknown>

Get a field from the request body

Get the underlying platform context object

getCookie(name: string)

Get a cookie from the request

getHeader(name: string)

Get the value of a request header

getParameter(name: string)

Get a parameter from the requested route

getQuery(name: string)

Get an item from the request query string

Get the underlying platform request object

getRequestState(name: string)

Get a request state item from the context

Get the underlying platform response object

getState(name: string)

Get a state item from the context

Get the requested URL

sendFile(path: string)

Set a file as a response

setBody(value: unknown)

Set the response body

setCookie(
name: string,
value: string,
options?: unknown,
)

Set a cookie on the response

setHeader(name: string, value: string)

Set a header on the response

setRequestState(name: string, value: unknown)

Set a request state item on the context

setState(name: string, value: unknown)

Set a state item on the context

setStatus(status: number)

Set a status code on the response