summaryrefslogtreecommitdiff
path: root/std/http/testdata/simple_https_server.ts
blob: 655457c94780137e2c8212d85cdeca91ee62d143 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
// This is an example of a https server
import { serveTLS } from "../server.ts";

const tlsOptions = {
  hostname: "localhost",
  port: 4503,
  certFile: "./http/testdata/tls/localhost.crt",
  keyFile: "./http/testdata/tls/localhost.key",
};
const s = serveTLS(tlsOptions);
console.log(`Simple HTTPS server listening on ${tlsOptions.hostname}:${tlsOptions.port}`);
const body = new TextEncoder().encode("Hello HTTPS");
for await (const req of s) {
  req.respond({ body });
}