Add README

This commit is contained in:
woxtu 2018-03-14 02:18:41 +09:00
parent 02065c4cca
commit 459ba27029
1 changed files with 35 additions and 0 deletions

35
README.md Normal file
View File

@ -0,0 +1,35 @@
# RouteKit
Type-safe URL routing for Swift.
```swift
struct UserIndex : Route {
let path = "/users"
func map(to url: URL, parameters: [String : String], queries: [String : String]) {
print("user index")
}
}
struct UserDetail : Route {
let path = "/users/{id}"
struct Parameters : Decodable {
let id: Int
}
func map(to url: URL, parameters: Parameters, queries: [String : String]) {
print("user detail: \(parameters.id)")
}
}
let router = Router<Void>()
router.append(route: UserIndex())
router.append(route: UserDetail())
router.push(url: URL(string: "/users/42")!) // user detail: 42
```
## License
Licensed under the MIT license.