Classes
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.
- browser(): Browser
The name and version of the browser extracted from the user agent string.
- cpu(): Cpu
The architecture of the CPU extracted from the user agent string.
- device(): Device
The model, type, and vendor of a device if present in a user agent string.
- engine(): Engine
The name and version of the browser engine in a user agent string.
- os(): Os
The name and version of the operating system in a user agent string.
- toJSON(): { browser: Browser; cpu: Cpu; device: Device; engine: Engine; os: Os; ua: string; }
Converts the current instance to a JSON representation.
- toString(): string
Converts the current instance to a string.
- ua(): string
A read only version of the user agent string related to the instance.
Used to construct an HTTP server.
- addrs(): Deno.Addr[]
Get the list of network addresses the server is listening on.
- close(): void
Immediately close the server listeners and associated HTTP connections.
- closed(): boolean
Get whether the server is closed.
- listenAndServe(): Promise<void>
Create a listener on the server, accept incoming connections, and handle requests on these connections with the given handler.
- listenAndServeTls(): Promise<void>certFile: string,keyFile: string
Create a listener on the server, accept incoming connections, upgrade them to TLS, and handle requests on these connections with the given handler.
- serve(listener: Deno.Listener): Promise<void>
Accept incoming connections on the given listener, and handle requests on these connections with the given handler.
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 ["*"]
is returned, implying any encoding is accepted.
Returns an array of languages accepted by the request, in order of
preference. If there are no languages supplied in the request, then ["*"]
is returned, imply any language is accepted.
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.
A helper function that takes the value from the If-Match header and a
calculated etag for the target. By using strong comparison, return true if
the values match, otherwise false.
A helper function that takes the value from the If-None-Match header and
a calculated etag for the target entity and returns false if the etag for
the entity matches the supplied value, otherwise true.
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.
Serves the files under the given directory root (opts.fsRoot).
Returns an HTTP Response with the requested file as the body.
Serves HTTP requests with the given handler.
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.
Interfaces
The browser as described by a user agent string.
The CPU information as described by a user agent string.
- architecture: string | undefined
The CPU architecture.
The device as described by a user agent string.
The browser engine as described by a user agent string.
Options for calculate.
Just the part of Deno.FileInfo that is required to calculate an ETag,
so partial or user generated file information can be passed.
The OS as described by a user agent string.
Interface for serveDir options.
- enableCors: boolean
Enable CORS via the "Access-Control-Allow-Origin" header.
- etagAlgorithm: AlgorithmIdentifier
The algorithm to use for generating the ETag.
- fsRoot: string
Serves the files under the given directory root. Defaults to your current directory.
- headers: string[]
Headers to add to each response
- quiet: boolean
Do not print request level logs. Defaults to false.
- showDirListing: boolean
Enable directory listing.
- showDotfiles: boolean
Serves dotfiles.
- showIndex: boolean
Serves index.html as the index file of the directory.
- urlRoot: string
Specified that part is stripped from the beginning of the requested pathname.
Interface for serveFile options.
- etagAlgorithm: AlgorithmIdentifier
The algorithm to use for generating the ETag.
- fileInfo: Deno.FileInfo
An optional FileInfo object returned by Deno.stat. It is used for optimization purposes.
Represents a message in the Server-Sent Event (SSE) protocol.
Information about the connection a request arrived on.
- localAddr: Deno.Addr
The local address of the connection.
- remoteAddr: Deno.Addr
The remote address of the connection.
Additional serve options.
- onError: (error: unknown) => Response | Promise<Response>
The handler to invoke when route handlers throw an error.
- onListen: (params: { hostname: string; port: number; }) => void
The callback which is called when the server started listening
- signal: AbortSignal
An AbortSignal to close the server and all connections.
Additional serve listener options.
- onError: (error: unknown) => Response | Promise<Response>
The handler to invoke when route handlers throw an error.
- onListen: (params: { hostname: string; port: number; }) => void
The callback which is called when the server started listening
- signal: AbortSignal
An AbortSignal to close the server and all connections.
Options for running an HTTP server.
Type Aliases
| STATUS_CODE.Unauthorized
| STATUS_CODE.PaymentRequired
| STATUS_CODE.Forbidden
| STATUS_CODE.NotFound
| STATUS_CODE.MethodNotAllowed
| STATUS_CODE.NotAcceptable
| STATUS_CODE.ProxyAuthRequired
| STATUS_CODE.RequestTimeout
| STATUS_CODE.Conflict
| STATUS_CODE.Gone
| STATUS_CODE.LengthRequired
| STATUS_CODE.PreconditionFailed
| STATUS_CODE.ContentTooLarge
| STATUS_CODE.URITooLong
| STATUS_CODE.UnsupportedMediaType
| STATUS_CODE.RangeNotSatisfiable
| STATUS_CODE.ExpectationFailed
| STATUS_CODE.Teapot
| STATUS_CODE.MisdirectedRequest
| STATUS_CODE.UnprocessableEntity
| STATUS_CODE.Locked
| STATUS_CODE.FailedDependency
| STATUS_CODE.UpgradeRequired
| STATUS_CODE.PreconditionRequired
| STATUS_CODE.TooManyRequests
| STATUS_CODE.RequestHeaderFieldsTooLarge
| STATUS_CODE.UnavailableForLegalReasons
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).
| STATUS_CODE.SwitchingProtocols
| STATUS_CODE.Processing
| STATUS_CODE.EarlyHints
An HTTP status that is a informational (1XX).
| STATUS_CODE.MovedPermanently
| STATUS_CODE.Found
| STATUS_CODE.SeeOther
| STATUS_CODE.UseProxy
| STATUS_CODE.TemporaryRedirect
| STATUS_CODE.PermanentRedirect
An HTTP status that is a redirect (3XX).
- headers: { get(key: string): string | null; }No documentation available
| STATUS_CODE.NotImplemented
| STATUS_CODE.BadGateway
| STATUS_CODE.ServiceUnavailable
| STATUS_CODE.GatewayTimeout
| STATUS_CODE.HTTPVersionNotSupported
| STATUS_CODE.VariantAlsoNegotiates
| STATUS_CODE.InsufficientStorage
| STATUS_CODE.LoopDetected
| STATUS_CODE.NotExtended
| STATUS_CODE.NetworkAuthenticationRequired
An HTTP status that is a server error (5XX).
An HTTP status code.
An HTTP status text.
| STATUS_CODE.Created
| STATUS_CODE.Accepted
| STATUS_CODE.NonAuthoritativeInfo
| STATUS_CODE.NoContent
| STATUS_CODE.ResetContent
| STATUS_CODE.PartialContent
| STATUS_CODE.MultiStatus
| STATUS_CODE.AlreadyReported
| STATUS_CODE.IMUsed
An HTTP status that is a success (2XX).
A handler for HTTP requests. Consumes a request and connection information and returns a response.
Variables
Contains the STATUS_CODE object which contains standard HTTP
status codes and provides several type guards for handling status codes
with type safety.
- Accepted: numberNo documentation available
- AlreadyReported: numberNo documentation available
- BadGateway: numberNo documentation available
- BadRequest: numberNo documentation available
- Conflict: numberNo documentation available
- ContentTooLarge: numberNo documentation available
- Continue: numberNo documentation available
- Created: numberNo documentation available
- EarlyHints: numberNo documentation available
- ExpectationFailed: numberNo documentation available
- FailedDependency: numberNo documentation available
- Forbidden: numberNo documentation available
- Found: numberNo documentation available
- GatewayTimeout: numberNo documentation available
- Gone: numberNo documentation available
- HTTPVersionNotSupported: numberNo documentation available
- IMUsed: numberNo documentation available
- InsufficientStorage: numberNo documentation available
- InternalServerError: numberNo documentation available
- LengthRequired: numberNo documentation available
- Locked: numberNo documentation available
- LoopDetected: numberNo documentation available
- MethodNotAllowed: numberNo documentation available
- MisdirectedRequest: numberNo documentation available
- MovedPermanently: numberNo documentation available
- MultiStatus: numberNo documentation available
- MultipleChoices: numberNo documentation available
- NetworkAuthenticationRequired: numberNo documentation available
- NoContent: numberNo documentation available
- NonAuthoritativeInfo: numberNo documentation available
- NotAcceptable: numberNo documentation available
- NotExtended: numberNo documentation available
- NotFound: numberNo documentation available
- NotImplemented: numberNo documentation available
- NotModified: numberNo documentation available
- OK: numberNo documentation available
- PartialContent: numberNo documentation available
- PaymentRequired: numberNo documentation available
- PermanentRedirect: numberNo documentation available
- PreconditionFailed: numberNo documentation available
- PreconditionRequired: numberNo documentation available
- Processing: numberNo documentation available
- ProxyAuthRequired: numberNo documentation available
- RangeNotSatisfiable: numberNo documentation available
- RequestHeaderFieldsTooLarge: numberNo documentation available
- RequestTimeout: numberNo documentation available
- ResetContent: numberNo documentation available
- SeeOther: numberNo documentation available
- ServiceUnavailable: numberNo documentation available
- SwitchingProtocols: numberNo documentation available
- Teapot: numberNo documentation available
- TemporaryRedirect: numberNo documentation available
- TooEarly: numberNo documentation available
- TooManyRequests: numberNo documentation available
- URITooLong: numberNo documentation available
- Unauthorized: numberNo documentation available
- UnavailableForLegalReasons: numberNo documentation available
- UnprocessableEntity: numberNo documentation available
- UnsupportedMediaType: numberNo documentation available
- UpgradeRequired: numberNo documentation available
- UseProxy: numberNo documentation available
- VariantAlsoNegotiates: numberNo documentation available
A record of all the status codes text.