Vapor
Swift,但在服务器上
Vapor 提供了一个安全、高性能且易于使用的基础,用于在 Swift 中构建 HTTP 服务器、后端和 API
import Vapor
let app = try await Application.make(.detect())
app.get("hello") { req in
"Hello, world!"
}
try await app.execute()
使用你已熟悉的工具构建服务器端
无需仅仅为了后端而从头学习一门语言(或组建另一支团队)。Vapor 基于 Apple 的 SwiftNIO 构建,因此你可以继续使用你已经熟悉和喜爱的语言。
高性能的 API 和服务器
Vapor 采用非阻塞、事件驱动的架构,让你能够构建高性能、可扩展的 API 和 HTTP 服务器。借助 Swift 的并发模型,你可以编写清晰、易维护、高效且易读的代码。
开始使用app.get("todos", ":id") { req async throws -> Todo in
let id: UUID = try req.parameters.require("id")
guard
let todo = try await Todo.find(id, on: req.db)
else {
throw Abort(.notFound)
}
return todo
}func search(req: Request) async throws -> [Todo] {
let name: String = try req.query.get(at: "name")
let results = try await Todo.query(on: req.db)
.filter(\.$number == name)
.all()
return results
}
这些出色应用背后的团队都在使用
查看完整列表
SwiftFiddle
SwiftFiddle is an online playground for creating, sharing and embedding Swift fiddles
查看实际效果
SwiftPackageIndex
The Swift Package Index is a searchable index of Swift packages and their compatibility with various platforms.
查看实际效果
Underway NYC
Quickly locate yourself on the official MTA map of NYC and get real-time train arrivals at that subway stop
查看实际效果
Litmaps
Litmaps is a browser-based research platform designed for clarity, comprehensiveness, and collaboration.
查看实际效果
加入最大的 Swift 后端开发者社区
Vapor 拥有超过 13,000 名成员的 Discord 社区将一路为你提供支持。提出问题、参与贡献,成为这个充满活力、友善的网络角落的一员。
加入我们的 Discord参与贡献获取使用 Swift 构建所需的全部工具
- 使用 Vapor Toolbox 轻松创建新项目
- 丰富的文档和 API 参考
- 构建后端和 API 所需的一切
- 全面支持 Swift 的并发模型


