O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Request data

Every route call gets passed a request object that can be used to grab query and path parameters.

The following example shows how to access JSON, Query, and form-encoded data from the request:

drop.post("hello") { request in     guard let name = request.data["name"]?.string else {         return "Please include a name"     }     return "Hello, \(name)!" } 

In this example, we read the request data and return a string.

Vapor also provides the means for session management, database connection, and view responses with HTML or Stencil template-included HTML pages. There is an example Vapor project (https://github.com/qutheory/vapor-example) that can be used and modified for our purposes. We are not going to explore Vapor in depth since it is still ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required