import * as mod from "https://deno.land/std@0.220.0/http/mod.ts";
Contains the STATUS_CODE
object which contains standard HTTP
status codes and provides several type guards for handling status codes
with type safety.
Examples
Example 1
Example 1
import {
STATUS_CODE,
STATUS_TEXT,
} from "https://deno.land/std@0.220.0/http/status.ts";
console.log(STATUS_CODE.NotFound); // Returns 404
console.log(STATUS_TEXT[STATUS_CODE.NotFound]); // Returns "Not Found"
Example 2
Example 2
import { isErrorStatus } from "https://deno.land/std@0.220.0/http/status.ts";
const res = await fetch("https://example.com/");
if (isErrorStatus(res.status)) {
// error handling here...
}
Classes
Used to construct an HTTP server. | |
Transforms server-sent message objects into strings for the client. | |
A representation of user agent string, which can be used to determine environmental information represented by the string. All properties are determined lazily. |
Variables
Contains the | |
A record of all the status codes text. |
Functions
Returns an array of media types accepted by the request, in order of preference. If there are no media types supplied in the request, then any media type selector will be returned. | |
Returns an array of content encodings accepted by the request, in order of
preference. If there are no encoding supplied in the request, then | |
Returns an array of languages accepted by the request, in order of
preference. If there are no languages supplied in the request, then | |
Calculate an ETag for an entity. When the entity is a specific set of data it will be fingerprinted as a "strong" tag, otherwise if it is just file information, it will be calculated as a weak tag. | |
Set the cookie header with empty value in the headers to delete it | |
Parse cookies of a header | |
Parse set-cookies of a header | |
A helper function that takes the value from the | |
A helper function that takes the value from the | |
A type guard that determines if the status code is a client error. | |
A type guard that determines if the status code is an error. | |
A type guard that determines if the status code is informational. | |
A type guard that determines if the status code is a redirection. | |
A type guard that determines if the status code is a server error. | |
Returns whether the provided number is a valid HTTP status code. | |
A type guard that determines if the status code is successful. | |
Parses a signed cookie to get its value. | |
Serves HTTP requests with the given handler. | |
Serves the files under the given directory root (opts.fsRoot). | |
Returns an HTTP Response with the requested file as the body. | |
Constructs a server, accepts incoming connections on the given listener, and handles requests on these connections with the given handler. | |
Serves HTTPS requests with the given handler. | |
Set the cookie header properly in the headers | |
Returns a promise with the signed cookie value from the given cryptographic key. | |
Returns a promise of a boolean indicating whether the signed cookie is valid. |
Interfaces
The browser as described by a user agent string. | |
Information about the connection a request arrived on. | |
Represents an HTTP Cookie. | |
I Cpu | The CPU information as described by a user agent string. |
The device as described by a user agent string. | |
The browser engine as described by a user agent string. | |
Options for | |
Just the part of | |
I Os | The OS as described by a user agent string. |
Interface for serveDir options. | |
Interface for serveFile options. | |
Additional serve options. | |
Additional serve listener options. | |
Options for running an HTTP server. | |
Represents a message in the Server-Sent Event (SSE) protocol. | |
Initialization parameters for |
Type Aliases
An HTTP status that is a client error (4XX). | |
Represents an entity that can be used for generating an ETag. | |
An HTTP status that is an error (4XX and 5XX). | |
A handler for HTTP requests. Consumes a request and connection information and returns a response. | |
An HTTP status that is a informational (1XX). | |
An HTTP status that is a redirect (3XX). | |
Loose copy of | |
An HTTP status that is a server error (5XX). | |
An HTTP status code. | |
An HTTP status text. | |
An HTTP status that is a success (2XX). |