feat: add native TLS serving

This commit is contained in:
2026-09-21 04:44:47 +08:00
parent 4daf3b211c
commit 847621d218
6 changed files with 160 additions and 2 deletions

View File

@@ -38,6 +38,18 @@ if err := application.RunWith(ctx, server, ":8080"); err != nil {
`omni.New()` 默认仍使用 `transport/nethttp` 路由;native 服务端是显式启用的预览实现,等协议和连接边界稳定后再考虑切换默认启动器。
TLS 可以直接作为 `App.RunWith` 的启动配置:
```go
server := native.New(nil)
server.TLSConfig = &tls.Config{Certificates: certificates}
if err := application.RunWith(ctx, server, ":8443"); err != nil {
log.Fatal(err)
}
```
需要自己持有 listener 或配置证书文件时,分别使用 `ServeTLS` 或 `RunTLS`;TLS 握手仍受 native 的读超时、连接上限和优雅关闭控制。
## 可移植路由规则(v0.3.0)
| 项目 | 约定 |