-
Notifications
You must be signed in to change notification settings - Fork 1
/
ServeHttpsInit.ts
53 lines (50 loc) · 1.61 KB
/
ServeHttpsInit.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { ConnInfo } from "./ConnInfo.ts";
import { Handler } from "./Handler.ts";
// function upgrade(req: Request, connInfo: ConnInfo) {
// const { socket, response } = Deno.upgradeWebSocket(req);
// const { url, headers, method } = req;
// const data = {
// ...connInfo,
// url,
// method,
// headers: Object.fromEntries(headers),
// };
// const body = JSON.stringify(data);
// console.log("upgrade", body);
// socket.addEventListener("open", () => {
// socket.send(body);
// socket.close();
// });
// return response;
// }
// async function main() {
// let { port, hostname, certFile, keyFile } = parse(Deno.args);
// if (port || hostname || certFile || keyFile) {
// port ??= 8000;
// hostname ??= "0.0.0.0";
// await serve_https(
// { request: handler, upgrade },
// { port, hostname, certFile, keyFile }
// );
// } else {
// console.log("Listening on http://localhost:8000");
// await serve(handler, { hostname: "0.0.0.0", port: 8000 });
// }
// }
export type ServeHttpsInit = Partial<
Deno.ListenTlsOptions & {
onNotFound?: Handler;
signal?: AbortSignal;
port?: number;
hostname?: string;
certFile?: string;
keyFile?: string;
onError?: (
// deno-lint-ignore no-explicit-any
reason: any,
request: Request,
connInfo: ConnInfo,
) => Response | PromiseLike<Response>;
onListen?: (params: { hostname: string; port: number }) => void;
}
>;