Nested routing

You can create a route with nested paths, such as /welcome/hello, by simply adding a route with the following nested path:

drop.get("welcome/hello/world") { req in  return "GET request for /welcome/hello/world"}

Additionally, you can split up the paths and pass them as additional parameters to the method, as follows:

drop.get("welcome", "hello", "world") { req in  return "GET request for /welcome/hello/world"}

This has the benefit of extracting values from the path into parameters that get passed into the req object.

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.