mirror of https://github.com/vapor/docs.git
addl controller updates
This commit is contained in:
parent
b26adad8f6
commit
3f70d3c523
|
|
@ -70,11 +70,12 @@ Controllers that conform to `ResourceRepresentable` can be easily registered int
|
|||
|
||||
```swift
|
||||
final class UserController {
|
||||
func index(_ request: Request) throws -> ResponseRepresentable {
|
||||
return try User.all().makeNode().converted(to: JSON.self)
|
||||
func index(_ req: Request) throws -> ResponseRepresentable {
|
||||
return try User.all().makeJSON()
|
||||
}
|
||||
|
||||
func show(_ request: Request, _ user: User) -> ResponseRepresentable {
|
||||
func show(_ req: Request) -> ResponseRepresentable {
|
||||
let user = try req.parameters.next(User.self)
|
||||
return user
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue