我试图通过使用Perfect和Turnstile-Perfect构建后端,使用Stormpath's iOS client-side notes tutorial(服务器端的swift和完美的Stormpath实现)来测试iOS服务器端用户身份验证旋转门完美。虽然我可以启动服务器并运行基本请求(参见帖子的底部),但用户auth根本不起作用,大概是因为我错过了设置数据库的步骤,我实际创建了数据库结构用于存储auth数据。具体来说,当我使用Postman用以下帖子测试我的服务器时:
{ "givenName": "Testing", "surname": "Tester", "email": "test@example.com", "password": "TestTest1" }
我收到以下错误:
The file /register was not found.
我如何建立这个?运行Stormpath的node.js实现时,我只运行:
npm install -g stormpath-spa-dev-server
什么是快速完美旋转门等同物?
当前服务器代码,用" main.swift"编写。 this project中的文件:
import PerfectLib
import PerfectHTTP
import PerfectHTTPServer
import TurnstilePerfect
import SQLite
// Create HTTP server.
let server = HTTPServer()
// The Turnstile instance
let turnstile = TurnstilePerfect()
server.setRequestFilters([turnstile.requestFilter])
server.setResponseFilters([turnstile.responseFilter])
// Register your own routes and handlers
func getHandler(request: HTTPRequest, response: HTTPResponse) {
response.appendBody(string: "get notes")
response.completed()
}
func postHandler(request: HTTPRequest, response: HTTPResponse) {
response.appendBody(string: "post notes")
response.completed()
}
var routes = Routes()
routes.add(method: .get, uri: "/notes", handler: {
request, response in getHandler(request: request, response: response)
}
)
routes.add(method: .post, uri: "/notes", handler: {
request, response in postHandler(request: request, response: response)
}
)
// Add the routes to the server.
server.addRoutes(routes)
// Set a listen port of 3000
server.serverPort = 3000
// Set a document root.
// This is optional. If you do not want to serve static content then do not set this.
// Setting the document root will automatically add a static file handler for the route /**
server.documentRoot = "./webroot"
// Gather command line options and further configure the server.
// Run the server with --help to see the list of supported arguments.
// Command line arguments will supplant any of the values set above.
configureServer(server)
do {
// Launch the HTTP server.
try server.start()
} catch PerfectError.networkError(let err, let msg) {
print("Network error thrown: \(err) \(msg)")
}