Skip to main content
Module

x/cav/deps.ts>http.serveTls

A server framework for Deno
Go to Latest
function http.serveTls
import { http } from "https://deno.land/x/cav@0.0.21/deps.ts";
const { serveTls } = http;

Serves HTTPS requests with the given handler.

You must specify keyFile and certFile options.

You can specify an object with a port and hostname option, which is the address to listen on. The default is port 8443 on hostname "0.0.0.0".

The below example serves with the default port 8443.

import { serveTls } from "https://deno.land/std@0.224.0/http/server.ts";
const certFile = "/path/to/certFile.crt";
const keyFile = "/path/to/keyFile.key";
serveTls((_req) => new Response("Hello, world"), { certFile, keyFile });
console.log("Listening on https://localhost:8443");

Parameters

handler: Handler

The handler for individual HTTPS requests.

options: ServeTlsInit

The options. See ServeTlsInit documentation for details.

Returns

Promise<void>