Skip to content

Instantly share code, notes, and snippets.

@islandjoe
Created May 14, 2018 10:10
Show Gist options
  • Save islandjoe/846f7cf40111f04044a503598f263d0a to your computer and use it in GitHub Desktop.
Save islandjoe/846f7cf40111f04044a503598f263d0a to your computer and use it in GitHub Desktop.
Replace a string part of the route with a Swift data type.
router.get("greets", String.parameter)
{ (req)-> String in 
  let name = try req.parameters.next(String.self)
  return "Hello, \(name)!"
}

This path will respond to requests for /greets/Broseph by printing out "Hello, Broseph!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment