deno - 创建 Deno https 服务器
问题描述
我正在寻找在 Deno 中创建 https 服务器的示例。我见过 Deno http 服务器的例子,但没有见过 https。
我尝试在谷歌搜索但没有找到结果
解决方案
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 });
}
推荐阅读
- python-3.x - 在 python 中与 None 一起获取输出
- python - 使用函数在 Pandas 中添加列
- html - 元素上的悬停效果在 CSS 中不起作用
- c++ - c++:进程可以自动回收 stl 对象上多余的分配内存吗?
- swift - 有没有办法通过在没有所有 didChange 管道的情况下连接到订阅者管道来检测 Swift ObservableObject 中的变化?
- css - 如何使用选择器选择没有类名的元素?
- php - 使用php计算两个lat long之间的距离并以米/公里显示
- python - 打印具有相同列的行
- python - 使用 re.findall() 的模式匹配给出不一致的结果
- java - 如何以编程方式将安卓手机连接到笔记本电脑上的热点设置?