我想处理这个 HTTP GET 请求 http://localhost:8080/route?wsdl 并返回一个静态文件
我已经开始使用这个路由处理程序 app.get("route") { req throws -> EventLoopFuture in
// req.query.get(String.self, at: "wsdl") throws an DecodingError
// I would like to check if the empty query parameter wsdl is present
// once I can check for the empty query parameter, I would use this for an if
//statement and in the case it is present return a static file
// then only a static file must be returned
return req.eventLoop.makeSucceededFuture(
req.fileio.streamFile(at: "file.wsdl")
)
}
}
我也尝试过这些路线,但没有成功: app.get("路线?wsdl") -> 这没有被调用,可能不应该工作
app.get("路线",":wsdl") -> 这没有被调用
// route handler
app.get("route") { req throws -> EventLoopFuture<Response> in
if let query = req.url.query,
query.count == 4,
query == "wsdl" {
return req.eventLoop.makeSucceededFuture(
req.fileio.streamFile(at: "file.wsdl")
)
}
else {
throw Abort(.notFound)
}
}