Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/sinco/tests/deps.ts>Drash.Request

Browser Automation and Testing Tool for Deno, written in full TypeScript
Latest
class Drash.Request
extends Request
import { Drash } from "https://deno.land/x/sinco@v4.1.0/tests/deps.ts";
const { Request } = Drash;

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

Methods

accepts(contentType: string): boolean

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

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

Get a body parameter of the request by the name

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,
pathParms: 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.