From 090d51aae5da095863940ada83f92d4b2ea52238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B3=BD=E7=86=99?= Date: Mon, 3 Oct 2016 18:27:49 +0800 Subject: [PATCH] Program syntax error drop.any("hello") { request in guard let name = request.data["name"].string else { throw Abort.badRequest } return "Hello, \(name)!" } --------------------------------------------------------------- drop.get("hello") { request in guard let name = request.data["name"]?.string else { throw Abort.badRequest } return "Hello, \(name)!" } --- guide/json.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/guide/json.md b/guide/json.md index d6ee83b4..2579ede9 100644 --- a/guide/json.md +++ b/guide/json.md @@ -11,12 +11,11 @@ JSON is an integral part of Vapor. It powers Vapor's [Config](config.md) and is JSON is automatically available in `request.data` alongside form-urlencoded data and query data. This allows you to focus on making a great API, not worrying about what content types data will be sent in. ```swift -drop.any("hello") { request in - guard let name = request.data["name"].string else { - throw Abort.badRequest - } - - return "Hello, \(name)!" +drop.get("hello") { request in + guard let name = request.data["name"]?.string else { + throw Abort.badRequest + } + return "Hello, \(name)!" } ```