From cd3a0dcb1a3bd3a9751f6f5fded67a615ccac9c7 Mon Sep 17 00:00:00 2001 From: Casper Rasmussen Date: Fri, 13 Jan 2017 20:03:17 +0100 Subject: [PATCH] Update query-parameters.md --- routing/query-parameters.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/routing/query-parameters.md b/routing/query-parameters.md index c7526c03..f918fca4 100644 --- a/routing/query-parameters.md +++ b/routing/query-parameters.md @@ -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)" } ```