Skip to content

Instantly share code, notes, and snippets.

@islandjoe
Created May 14, 2018 10:29
Show Gist options
  • Save islandjoe/d0e5751e70a11e81a794e1901dfd15a5 to your computer and use it in GitHub Desktop.
Save islandjoe/d0e5751e70a11e81a794e1901dfd15a5 to your computer and use it in GitHub Desktop.
Listing path components in a Vapor route.
router.get("page", Int.parameter, String.parameter)
{ (req)-> String in
  let num = try req.parameters.next(Int.self)
  let section = try req.parameters.next(String.self)
  
  return "Loading page \(num), section \(section)."
}

Results in this route: /page/23/C

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