hummingbird
v2.5.0


轻巧,灵活,现代服务器框架以Swift编写。
Hummingbird是一种轻巧,灵活的现代Web应用程序框架,它在基于Swiftnio的服务器实现之上运行。它旨在需要最小数量的依赖项。
它提供了一个路由器,用于将不同的端点引导到其处理程序,中间件,用于处理请求,然后再处理您的处理程序并处理返回的响应,自定义编码/解码请求/响应,TLS和HTTP2。
import Hummingbird
// create router and add a single GET /hello route
let router = Router ( )
router . get ( " hello " ) { request , _ -> String in
return " Hello "
}
// create application using router
let app = Application (
router : router ,
configuration : . init ( address : . hostname ( " 127.0.0.1 " , port : 8080 ) )
)
// run hummingbird application
try await app . runService ( )Hummingbird的核心设计至少,并通过扩展提供了其他功能。以下是一些官方扩展:
HummingbirdRouter :使用结果构建器的替代路由器HummingbirdTLS :TLS支持HummingbirdHTTP2 :http2升级支持HummingbirdTesting :测试蜂鸟项目的助手功能以下扩展名在单独的存储库中可用:
您可以在此处找到蜂鸟的参考文档和用户指南。蜂鸟示例存储库有许多库的用途的示例。
将以下内容添加到您的Package.swift 。Swift文件:
dependencies: [
. package ( url : " https://github.com/hummingbird-project/hummingbird.git " , from : " 2.0.0 " )
] ,
targets: [
. executableTarget (
name : " MyApp " ,
dependencies : [
. target ( name : " Hummingbird " ) ,
] ) ,
]或使用SwiftPM在软件包上运行以下命令,用目标名称替换MyApp :
swift package add - dependency https : //github.com/hummingbird-project/hummingbird.git --from 2.0.0
swift package add - target - dependency Hummingbird MyApp我们欢迎对蜂鸟的贡献!在提交拉动请求之前,请阅读我们的贡献指南。
蜂鸟在Apache 2.0许可下发布。