Skip to main content

@std/http@0.215.0

latest
Works with
It is unknown whether this package works with Browsers, Deno, Node.js, Cloudflare Workers, Bun
It is unknown whether this package works with Browsers
It is unknown whether this package works with Deno
It is unknown whether this package works with Node.js
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Bun
JSR Score70%
Published2 years ago (0.215.0)

Classes

c
Server(serverInit: ServerInit)

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(
    certFile: string,
    keyFile: string
    ): Promise<void>

    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

f
serve(
handler: Handler,
options?: ServeInit
): Promise<void>

Serves HTTP requests with the given handler.

f
serveListener(
listener: Deno.Listener,
handler: Handler,
options?: ServeListenerOptions
): Promise<void>

Constructs a server, accepts incoming connections on the given listener, and handles requests on these connections with the given handler.

f
serveTls(
handler: Handler,
options: ServeTlsInit
): Promise<void>

Serves HTTPS requests with the given handler.

Interfaces

I

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.

I

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.

I

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.

I

Options for running an HTTP server.

  • handler: Handler

    The handler to invoke for individual HTTP requests.

  • onError: (error: unknown) => Response | Promise<Response>

    The handler to invoke when route handlers throw an error.

I

Initialization parameters for serveTls.

  • cert: string

    Cert chain in PEM format

  • certFile: string

    The path to the file containing the TLS certificate

  • key: string

    Server private key in PEM format

  • keyFile: string

    The path to the file containing the TLS private key.

Type Aliases

T
Handler = (
request: Request,
connInfo: ConnInfo
) => Response | Promise<Response>

A handler for HTTP requests. Consumes a request and connection information and returns a response.

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@std/http

Import symbol

import * as mod from "@std/http/server";
or

Import directly with a jsr specifier

import * as mod from "jsr:@std/http/server";