Skip to main content
Module

x/cav/http.ts

A server framework for Deno
Go to Latest
import * as mod from "https://deno.land/x/cav@0.0.21/http.ts";

Variables

Serves HTTP requests with the given handler. (Stacks and Rpcs are handlers.) You can specify an object with a port and hostname option, which is the address to listen on. The default is port 8000 on hostname "0.0.0.0". This is a re-export of the serve() function from https://deno.land/std/http/server.ts.

Functions

Creates a cookie tied to the given request and response headers. The keys provided will be used for cookie signing; if no keys are provided, a random fallback key will be used. Keys need to be provided in an array, making key rotation easier.

Creates an EndpointResponse from the provided body, which is serialized using the top-level serializeBody function. If the provided body is already a Response object, it will be returned with the init headers applied (if there are any). In that case, the status and statusText init options will be ignored. Extra serializers can be used to extend the data types that can be serialized.

Returns a parsed body from a given request after checking size constraints. Uses deserializeBody to deserialize the request body.

Generates or returns a previously generated RequestContext for a given request. If this is the first time requestContext is being called for the given request, the RequestContext object is generated and returned. Every other time the request passes through this function, the same object generated on the first call is returned without further modification.

Constructs a new server instance. This is a simple function wrapper around the Server constructor from https://deno.land/std/http/server.ts.

The server-side equivalent of the wrapWebSocket function in the client module. Returns the Socket instance and a Response which should be returned by the handler for the socket upgrade to complete successfully.

Interfaces

Cav's cookie interface. This interface provides synchronous access to cookie values. The actual signing of signed cookies needs to be asynchronous, however. Once you are done accessing and modifying the cookie, you need to call the async "flush()" to sync cookie updates to the response headers that were provided when the cookie was initialized.

Limits what paths/domains a cookie should be deleted for.

Extends the Deno default cookie set options to include the "signed" flag.

Initializer options for the endpointResponse() function.

A metadata cache object generated once for every Request handled with a Cav handler (Stacks and Rpcs).

Type Aliases

Options for serving an http handler. This is a re-export of the ServeInit type from https://deno.land/std/server.ts.

An http server. This is a re-export of the Server type from https://deno.land/std/http/server.ts.

Options for running an http server. This is a re-export of the ServerInit type from https://deno.land/std/http/server.ts.