Skip to main content
Module

std/http/server.ts>ServerInit

Deno standard library
Go to Latest
interface ServerInit
import { type ServerInit } from "https://deno.land/std@0.117.0/http/server.ts";

Options for running an HTTP server.

Properties

optional
addr: string

Optionally specifies the address to listen on, in the form "host:port".

If the port is omitted, :80 is used by default for HTTP when invoking non-TLS methods such as Server.listenAndServe, and :443 is used by default for HTTPS when invoking TLS methods such as Server.listenAndServeTls.

If the host is omitted, the non-routable meta-address 0.0.0.0 is used.

handler: Handler

The handler to invoke for individual HTTP requests.

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

The handler to invoke when route handlers throw an error.

The default error handler logs and returns the error in JSON format.