Skip to main content
Module

x/attain/mod.ts>Response

Deno API middleware Server
Latest
class Response
import { Response } from "https://deno.land/x/attain@1.1.2/mod.ts";

Constructors

new
Response(_serverRequest: Request)

Type Parameters

optional
T = any

Properties

readonly
getBody

Return the current body data

readonly
getHeaders: Headers

Return the current header class object.

readonly
getResponse: Response

Return the current response object which will be used for responding

readonly
getStatus: number | undefined

Return the current status number

readonly
getStatusText: string | undefined
readonly
processDone: boolean
readonly
serverRequest: Request

Return the original ServerRequest class object.

Methods

private
format(obj: any)
body(body: ContentsType)

Set the body without response

destroy(): void
download(filePath: string, name?: string): Promise<void>

Serve the static file and force the browser to download it.

end(): Promise<void>

End the current process and respond

executePendingJobs(request: AttainRequest): Promise<void>

Execute pend jobs, It's automatically executed after calling the end() or send().

getHeader(name: string)

Get the header data by a key

pend(...fn: CallBackType<T>[]): void

Pend the jobs which will execute right before responding.

redirect(url: string | "back")

Redirection

removeHeader(name: string)

Remove data from the header by a key.

send(contents: ContentsType): Promise<void>

Set the body and respond with response object.

sendFile(filePath: string): Promise<void>

Serve the static files

setContentType(type: string)

Set the Content-Type header It'll append the data

setHeader(name: string, value: string)

Set the header data

Replace the current entire header object with new Headers

status(status: number, statusText?: string)

Set the status