deno - 创建一个Deno https服务器

标签 deno

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

我曾尝试在Google中搜索,但未找到任何结果

最佳答案

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 });
}

关于deno - 创建一个Deno https服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55912807/

相关文章:

node.js - Deno 脚本与 Node.js 兼容吗?

node.js - Deno:服务器发送事件

typescript - 如何退出 Deno? (process.exit 的模拟)

typescript - VSCode - 设置带有 Deno(后端)文件夹和 Vite(前端)文件夹的 monorepo

Deno 中的 Node.js 的 __dirname 和 __filename 等效项

firebase - 使用 Deno djwt 验证 Firebase ID token (JWT)

node.js - 什么是 Deno 等价于 Node.js Buffer.from(string)

javascript - 如何在 Deno 中写入文件?

Deno 对 CWD 的读访问

javascript - 无法解析 deno 中的查询