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",
|
|
|
|
port: 4503,
|
|
|
|
certFile: "./http/testdata/tls/localhost.crt",
|
2019-12-02 19:14:25 -05:00
|
|
|
keyFile: "./http/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(
|
|
|
|
`Simple HTTPS server listening on ${tlsOptions.hostname}:${tlsOptions.port}`
|
|
|
|
);
|
2019-11-04 13:45:29 -05:00
|
|
|
const body = new TextEncoder().encode("Hello HTTPS");
|
|
|
|
for await (const req of s) {
|
|
|
|
req.respond({ body });
|
|
|
|
}
|