【发布时间】:2019-02-07 03:19:33
【问题描述】:
我正在为 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 公司会考虑使用此功能。也许我应该报告它。 任何人都知道我的问题可能是什么解决方案?请告诉。 谢谢。
【问题讨论】:
标签: swift url-redirection perfect server-side-swift