9 karma · joined Jan 30, 2014 (12y ago) · 5 submissions
comment 10y ago · link · parent
> We would like to provide a package index in the future, and are investigating possible solutions.
[1]: https://github.com/apple/swift-package-manager/blob/master/D...
comment 10y ago · link · parent
Check out Frank (https://github.com/nestproject/Frank#routes) which offers type-safe and compile-time safe path routing.
You define a closure to handle requests matching paths with type-safety. You are passed the correct parameter types and the correct amount of parameters directly to your closure. This gives you compile type safety.
// Handle GET requests to path /users/{username}
get("users", *) { (request, username: String) in
return "Hello \(username)"
}
In contrast, without this compile-time safety you will most likely be passed an array of Strings and you will have to pull items out. Route.get("users/:username") { request in
if let username = request.parameters["username"] {
// Return something with username
} else {
// TODO Return 404
}
}
Here you have to manually validate these parameters, there is also the lack of compile time safety in the way you are writing a hard-coded string for each parameters. There is a string "username" twice, both the path and when you pull out the parameter from the array. There is a large room for user error or typos here.comment 10y ago · link · parent
A user should be free to choose their favourite web framework and then choose the best web server for their needs.
comment 12y ago · link · parent