2020-01-21 10:01:55 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2019-11-04 13:45:29 -05:00
|
|
|
// This is an example of a https server
|
|
|
|
import { serveTLS } from "../server.ts";
|
|
|
|
|
|
|
|
const tlsOptions = {
|
|
|
|
hostname: "localhost",
|
2020-03-24 12:24:58 -04:00
|
|
|
port: 4503,
|
2020-09-14 06:58:43 -04:00
|
|
|
certFile: "./testdata/tls/localhost.crt",
|
|
|
|
keyFile: "./testdata/tls/localhost.key",
|
2019-11-04 13:45:29 -05:00
|
|
|
};
|
|
|
|
const s = serveTLS(tlsOptions);
|
2019-12-02 19:14:25 -05:00
|
|
|
console.log(
|
2020-09-14 06:58:43 -04:00
|
|
|
`Simple HTTPS server listening on ${tlsOptions.hostname}:${tlsOptions.port}`,
|
2019-12-02 19:14:25 -05:00
|
|
|
);
|
2019-11-04 13:45:29 -05:00
|
|
|
const body = new TextEncoder().encode("Hello HTTPS");
|
|
|
|
for await (const req of s) {
|
|
|
|
req.respond({ body });
|
|
|
|
}
|