import * as cav from "https://deno.land/x/cav@0.0.14/http.ts";
Variables
A special 404 HttpError that should be thrown whenever a handler is refusing to respond to a request due to the path not matching constraints. This is thrown by Rpcs when path matching fails. If a Stack catches this error, it will continue looking for matching routes. |
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. | |
Returns a parsed body from a given request after checking size constraints. Uses unpackBody to unpack the request body. | |
Generates or returns a previously generated RequestData for a given request. If this is the first time requestData is being called for the given request, the RequestData 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. | |
Creates a TypedResponse from the provided body, which undergoes packing via packBody. Extra packers can be provided using the "packers" option on the init argument. If a Response is passed in as the body, its body will be used without re-packing; headers and status/text will still be updated to match the provided init. | |
Shorthand function for quickly serving a Handler. This function is a one-liner: | |
Response factory for serving static assets. Asset resolution uses the provided ServeAssetOptions, the Request is only used for caching headers like ETag etc. | |
Creates a Server using the provided ServerInit. Note that there is no "onError" init option; errors that bubble up to the Server level are logged and a 500 Response is sent back to the client. You should handle errors as close as possible to where the error occurred, for example using the Rpc "onError" init option. | |
The server-side equivalent of the wrapWebSocket function in the client module. Returns 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. In order to compensate for this, once you are done accessing and modifying the cookie, you need to call the async "flush()" in order 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. | |
A metadata object generated once for every request. | |
I Res | A ResponseInit applied to the Rpc response after resolving and packing the value to send to the client. The Headers object is always available. If the resolved value is a Response object already, the status and statusText will be ignored but the headers will still be applied. |
Options controlling how assets are found and served. | |
The standard http.Server type, but with a type parameter indicating the type of the handler that was passed in. The handler will usually be a Stack but could be any other type of Handler. | |
The standard http.ServerInit type with a type parameter indicating the type of the handler this server is serving. Additionally, the "onError" property has been omitted; errors in Cav should be handled at the Rpc level, as close as possible to where the error occurred. When an error bubbles up to the Server level, it will be logged and a 500 Response will be sent to the client. | |
A Response, but with an unused type parameter indicating the type of the response body. | |
Initializer options for a TypedResponse. Adds packers to ResponseInit. |
Type Aliases
The ServerInit options available when using the serve() shorthand function. |