From 76c44dbf7eb684808068b9489921bda629dffd4a Mon Sep 17 00:00:00 2001 From: Ron Pinz Date: Thu, 9 Nov 2017 22:10:57 -0500 Subject: [PATCH 1/2] update deprecated add functionality --- Sources/RoutingHandlers.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/RoutingHandlers.swift b/Sources/RoutingHandlers.swift index 868c80e..9e529f3 100644 --- a/Sources/RoutingHandlers.swift +++ b/Sources/RoutingHandlers.swift @@ -56,9 +56,9 @@ func makeURLRoutes() -> Routes { var api2Routes = Routes(baseUri: "/v2") // Add the main API calls to version 1 - api1Routes.add(routes: api) + api1Routes.add(api) // Add the main API calls to version 2 - api2Routes.add(routes: api) + api2Routes.add(api) // Update the call2 API api2Routes.add(method: .get, uri: "/call2", handler: { _, response in response.setBody(string: "API v2 CALL 2") @@ -66,8 +66,8 @@ func makeURLRoutes() -> Routes { }) // Add both versions to the main server routes - routes.add(routes: api1Routes) - routes.add(routes: api2Routes) + routes.add(api1Routes) + routes.add(api2Routes) // Check the console to see the logical structure of what was installed. print("\(routes.navigator.description)") From 51426ce03b65042feb91ea3c8918f717cd2d3b7b Mon Sep 17 00:00:00 2001 From: Ron Pinz Date: Thu, 9 Nov 2017 22:16:51 -0500 Subject: [PATCH 2/2] Update to remove warnings about Optional --- Sources/RoutingHandlers.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/RoutingHandlers.swift b/Sources/RoutingHandlers.swift index 9e529f3..90204d7 100644 --- a/Sources/RoutingHandlers.swift +++ b/Sources/RoutingHandlers.swift @@ -101,7 +101,8 @@ func echo4Handler(request: HTTPRequest, _ response: HTTPResponse) { } func rawPOSTHandler(request: HTTPRequest, _ response: HTTPResponse) { - response.appendBody(string: "Raw POST handler: You POSTED to path \(request.path) with content-type \(request.header(.contentType)) and POST body \(request.postBodyString)") + // see https://stackoverflow.com/a/42543251 for explanation of "as Optional" usage + response.appendBody(string: "Raw POST handler: You POSTED to path \(request.path) with content-type \(request.header(.contentType) as Optional) and POST body \(request.postBodyString as Optional)") response.completed() }