Skip to main content
Module

x/drash/mod.ts>Request

A microframework for Deno's HTTP server with zero third-party dependencies
Go to Latest
class Request
extends Request
import { Request } from "https://deno.land/x/drash@v2.7.0/mod.ts";

A class that holds the representation of an incoming request

Constructors

new
Request(
originalRequest: Request,
pathParams: Map<string, string>,
connInfo: ConnInfo,
)

Construct an object of this class.

This class is just a wrapper around the native Request object. The only reason we wrap around the native Request object is so we can add more methods to interact with the native Request object (e.g., req.bodyParam()).

Properties

conn_info: ConnInfo
readonly
end_lifecycle: boolean
readonly
original: Request

Methods

accepts(contentType: string): boolean

Check if the content type in question are accepted by the request.

bodyAll<T>(): ParsedBody | T

Get all body params.

bodyParam<T>(name: string): T | undefined

Get a body parameter of the request by the name

end(): void

Set this request to end early? Calling this will tell the request to stop where it is at in the request-resource-response lifecycle and immediately return a response.

getCookie(name: string): string

Get a cookie value by the name that is sent in with the request.

pathParam(name: string): string | undefined

Get a path parameter from the request based on the request's URL and the resource path it matched to.

queryParam(name: string): string | undefined

Find a query string parameter.

Static Methods

create(
request: Request,
pathParams: Map<string, string>,
connInfo: ConnInfo,
)

Create a Drash request object. We use this method to create request objects because we need to use async-await and cannot use them in constructor methods. This is the only reason for this abstraction.