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許可下發布。