创建 Deno https 服务器

jay*_*mar 9 deno

我正在寻找在 Deno 中创建 https 服务器的示例。我看过 Deno http 服务器的例子,但没有看过 https。

我试过在谷歌搜索,但没有找到结果

Kev*_*ian 6

serveTLS 与 Deno 0.23.0 一起登陆:

示例用法:

import { serveTLS } from "https://deno.land/std/http/server.ts";

const body = new TextEncoder().encode("Hello HTTPS");
const options = {
  hostname: "localhost",
  port: 443,
  certFile: "./path/to/localhost.crt",
  keyFile: "./path/to/localhost.key",
};
// Top-level await supported
for await (const req of serveTLS(options)) {
  req.respond({ body });
}
Run Code Online (Sandbox Code Playgroud)


小智 -2

你检查过 DENO ABC 了吗?它是创建 Web 应用程序的更好框架。欲了解更多信息,请访问https://deno.land/x/abc/README.md

import { abc } from "https://deno.sh/abc/mod.ts";
const app = abc();
app
  .get("/hello", c => {
    return "Hello, Abc!";
  })
  .start("0.0.0.0:8080");
Run Code Online (Sandbox Code Playgroud)