MacroApp 构建于 MacroExpress 之上,提供类似 SwiftUI 的声明式端点设置。
它比 MacroExpress 更加有主见。
MacroExpress 是一个小型、无主见的 “别挡我的道” / “我不想
wait
” 的 Swift 异步 Web 框架。它着重于在 Swift 中复刻 Node API。但以类型安全且快速的方式实现。
MacroApp 只是构建于 MacroExpress 之上的语法糖(使用 Swift 函数构建器)。配置会被评估为一个常规的基于 MacroExpress 的应用(包含路由和中间件)。
MacroApp
@main
struct HelloWorld: App {
var body: some Endpoints {
Use(logger("dev"), bodyParser.urlencoded())
Route("/admin") {
Get("/view") { req, res, _ in res.render("admin-index.html") }
Render("help", template: "help")
}
Get { req, res, next in
res.render("index.html")
}
}
}
代替这种传统的路由设置(如在 MacroExpress 中)
let app = express()
app.use(logger("dev"), bodyParser.urlencoded())
app.route("/admin")
.get("/view") { req, res, _ in res.render("admin-index.html") }
app.get("/") { req, res, _ in res.render("index.html") }
app.listen(1337) {
console.log("Server listening on https://:1337")
}
macro.core.numthreads
macro.core.iothreads
macro.core.retain.debug
macro.concat.maxsize
macro.streams.debug.rc
macro.router.debug
macro.router.matcher.debug
MacroExpress 由 Helge Heß / ZeeZide 为您带来。我们喜欢反馈、GitHub 星星、酷炫的合同工作,以及任何您能想到的赞扬形式。
在 Noze.io Slack 上有一个 #microexpress
频道。欢迎加入!