我正在为 Web 服务使用服务器端 Swift 完美框架。用于提供静态/动态内容的 Mustache 模块。
我想在成功身份验证重定向到主页后实现登录功能。“我到处搜索,但没有找到任何重定向到 url 的功能”
这是我用于实现登录的代码-
func signin(request:HTTPRequest, response: HTTPResponse) {
do {
var errorMessage:String;
var values = MustacheEvaluationContext.MapType()
let email:String = request.param(name: "email")!
let password:String = request.param(name: "password")!
print("Email -> \(email) & Password -> \(password)")
//After Authentication
//Yay I want to go back to home page.
mustacheRequest(request: request, response: response, handler: MustacheHelper(values: values), templatePath: webroot + "/index.html")
// Sadly this doesn't work, it just renders the homepage without changing the url or 'without redirecting'
response.completed()
} catch {
print(error)
logError(error.localizedDescription)
response.setBody(string: "An error occured \(error)").completed()
}
}
我认为PerfectlySoft 公司fogot 把这个功能。也许我应该报告它。任何人都知道我的问题可能是什么解决方案?请告诉。谢谢。