Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Response

import { Response } from "https://raw.githubusercontent.com/mandarineorg/mandarinets/master/deps.ts";

An interface to control what response will be sent when the middleware finishes processing the request.

class Response {
constructor(request: Request);
get body(): Body | BodyFunction;
set body(value: Body | BodyFunction);
get headers(): Headers;
set headers(value: Headers);
get status(): Status;
set status(value: Status);
get type(): string | undefined;
set type(value: string | undefined);
get writable(): boolean;
 
addResource(rid: number): void;
destroy(closeResources?): void;
redirect(url: string | URL): void;
redirect(url: REDIRECT_BACK, alt?: string | URL): void;
redirect(url: string | URL | REDIRECT_BACK, alt?: string | URL): void;
async toDomResponse(): Promise<globalThis.Response>;
async toServerResponse(): Promise<ServerResponse>;
}

§Constructors

§
new Response(request: Request)
[src]

§Properties

§
body: Body | BodyFunction
[src]

The body of the response. The body will be automatically processed when the response is being sent and converted to a Uint8Array or a Deno.Reader.

Automatic conversion to a Deno.Reader occurs for async iterables.

§
headers: Headers
[src]

Headers that will be returned in the response.

§
status: Status
[src]

The HTTP status of the response. If this has not been explicitly set, reading the value will return what would be the value of status if the response were sent at this point in processing the middleware. If the body has been set, the status will be 200 OK. If a value for the body has not been set yet, the status will be 404 Not Found.

§
type: string | undefined
[src]

The media type, or extension of the response. Setting this value will ensure an appropriate Content-Type header is added to the response.

§
writable: boolean readonly
[src]

A read-only property which determines if the response is writable or not. Once the response has been processed, this value is set to false.

§Methods

§
addResource(rid: number): void
[src]

Add a resource to the list of resources that will be closed when the request is destroyed.

§
destroy(closeResources?): void
[src]

Release any resources that are being tracked by the response.

@param closeResources

close any resource IDs registered with the response

§
redirect(url: string | URL): void
[src]

Sets the response to redirect to the supplied url.

If the .status is not currently a redirect status, the status will be set to 302 Found.

The body will be set to a message indicating the redirection is occurring.

redirect(url: REDIRECT_BACK, alt?: string | URL): void
[src]

Sets the response to redirect back to the referrer if available, with an optional alt URL if there is no referrer header on the request. If there is no referrer header, nor an alt parameter, the redirect is set to /.

If the .status is not currently a redirect status, the status will be set to 302 Found.

The body will be set to a message indicating the redirection is occurring.

redirect(url: string | URL | REDIRECT_BACK, alt?: string | URL): void
[src]
§
toDomResponse(): Promise<globalThis.Response>
[src]
§
toServerResponse(): Promise<ServerResponse>
[src]

Take this response and convert it to the response used by the Deno net server. Calling this will set the response to not be writable.

Most users will have no need to call this method.