import { ResponseBuilder } from "https://dotland.deno.dev/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",
}
})