mirror of https://github.com/vapor/docs.git
Cannot use `id` in Swift (#407)
* Cannot use id in Swift `error: 'id' is unavailable in Swift: 'id' is not available in Swift; use 'Any'` https://developer.apple.com/swift/blog/?id=39 * Update routing.md
This commit is contained in:
parent
f7fa580ad1
commit
95bba5fa2e
|
|
@ -40,7 +40,7 @@ public func routes(_ router: Router) throws {
|
|||
router.get("hello") { req in
|
||||
return "Hello, world!"
|
||||
}
|
||||
|
||||
|
||||
/// ...
|
||||
}
|
||||
```
|
||||
|
|
@ -50,12 +50,12 @@ See [Getting Started → Content](content.md) for more information about what
|
|||
## Parameters
|
||||
|
||||
Sometimes you may want one of the components of your route path to be dynamic. This is often used when
|
||||
you want to get an item with a supplied identifier, e.g., `GET /users/:id`
|
||||
you want to get an item with a supplied identifier, e.g., `GET /users/:userID`
|
||||
|
||||
```swift
|
||||
router.get("users", Int.parameter) { req -> String in
|
||||
let id = try req.parameters.next(Int.self)
|
||||
return "requested id #\(id)"
|
||||
let userID = try req.parameters.next(Int.self)
|
||||
return "requested user id #\(userID)"
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue