import { type ServeOptions } from "https://deno.land/x/ayonli_jsext@v0.9.72/workerd/http.ts";
Options for serving HTTP requests, used by serve.
Properties
Instructs how the server should be deployed. classic
means serve
will start the server itself (or use addEventListener("fetch")
in
service workers), while module
means using the Server instance
as an ES module with the syntax export default serve({ ... })
.
NOTE: This option is only adjustable in Node.js, Deno, Bun and Cloudflare
Workers, in other environments, it will be ignored and will default to
classic
. It is recommended to set this option to module
in Cloudflare
Workers.
The handler for processing HTTP requests.
The hostname to listen on. Default is 0.0.0.0
.
NOTE: This option is ignored in workers or when the type
is module
.
The port to listen on. If not set, the server will first try to use the
8000
port, and if it's not available, it will use a random port.
NOTE: This option is ignored in workers or when the type
is module
.
The certificate key for serving HTTPS/HTTP2 requests.
NOTE: This option is ignored in workers or when the type
is module
.
The certificate for serving HTTPS/HTTP2 requests.
NOTE: This option is ignored in workers or when the type
is module
.
The WebSocket handler for processing WebSocket connections. Normally this
options is not set and the WebSocket is handled per request inside the
fetch
handler.
A listener that will be called when the fetch
handler throws an error.
By default, the server will respond with a 500 Internal Server Error
response, we can override this behavior by setting this option.
A listener that will be called when the server starts listening. By default, the server will log the address it's listening on, we can override this behavior by setting this option.
NOTE: This option is ignored in workers or when the type
is module
.
Extra headers to be sent with the response. These headers are only set when they're not present.
By default, the server will set the Server
header to the runtime name
and its version. We can set this option to override the default behavior,
or set it to null
to disable the default headers.