import { ResponseBuilder } from "https://deno.land/x/drash@v3.0.0-beta.2/src/modules/builders/ResponseBuilder.ts";
A builder to help build a Response
object. This is useful if the response's
data needs to be modified throughout a lifecycle, but not instantiated into a
Response
object until required.
Examples
Example 1
Example 1
const builder = new ResponseBuilder();
// This call ...
const resA = builder
.headers({
"x-some-header": "Some Value"
"x-some-other-header": "Some Other Value",
})
.body("Nope.")
.status(400)
.statusText("Bad Request")
.build();
// ... results in the same response as this call ...
const resB = new Response("Nope.", {
status: 400,
statusText: "Bad Request",
headers: {
"x-some-header": "Some Value"
"x-some-other-header": "Some Other Value",
}
})
Properties
protected
response_body: BodyInit | nullprotected
response_headers: Headersprotected
response_init: ResponseInitMethods
build()
headers(headers: Record<string, string>)
Set the headers (using key-value pairs) the built response will use as its ResponseInit.headers.
status(status: number)
Set the status the built response will use as its ResponseInit.status.
statusText(statusText: string)
Set the ResponseInit.statuText property.