Module

x/drash/mod.ts>Response

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

Properties

body: BodyInit | null
headers: Headers
status: number
statusText: string
upgraded: boolean
upgraded_response: Response | null

Methods

deleteCookie(name: string, attributes?: { domain: string; path?: string; }): void

Delete a cookie for the response.

download(
filepath: string,
contentType: string,
headers?: Record<string, string>,
): void

Set the body of this response as a downloaded type given the filepath, filename, and content type of the downloadable type.

file(
filepath: string,
status?: number,
headers?: Record<string, string>,
): void

Set the body of this response as the contents of the given filepath. The Content-Type header will be set automatically based on the extension of the filepath.

html(
html: string,
status?: number,
headers?: Record<string, string>,
): void

Set the body of this response as HTML.

json(
json: object,
status?: number,
headers?: Record<string, string>,
)

Set the body of this response as JSON.

render(_filepath: string, _data: unknown): boolean | string

This method allows users to make this.response.render() calls in resources. This method is also used by Tengine:

https://github.com/drashland/deno-drash-middleware/tree/master/tengine

send<T extends BodyInit>(contentType: string, body: T): void

Set thie body of this response.

setCookie(cookie: Cookie): void

Set a cookie on the response to be handled by the client.

text(
text: string,
status?: number,
headers?: Record<string, string>,
)

Set the body of this response as text.

upgrade(response: Response): void

Upgrade the response.

xml(
xml: string,
status?: number,
headers?: Record<string, string>,
)

Set the body of this response as XML.