Update query-parameters.md

This commit is contained in:
Casper Rasmussen 2017-01-13 20:03:17 +01:00 committed by GitHub
parent 5b2e57dff9
commit cd3a0dcb1a
1 changed files with 3 additions and 4 deletions

View File

@ -26,10 +26,9 @@ To use this syntax first we need to ensure the query object is present with a `g
```swift
drop.get("comments") { request in
guard let query = request.query else {
throw Abort.badRequest
}
let rating = try query.extract("rating") as Int
guard let rating = request.query?["rating"]?.int else {
throw Abort.custom(status: .preconditionFailed, message: "Please include a rating")
}
return "You requested comments with rating greater than #\(rating)"
}
```