swiftkitura

Multiple parameters in codable routes in kitura


I'm trying to figure out how codable routes with parameters in Kitura work. The default example is always something simple like:

GET /todos
GET /todos/<id>

What I'm looking for is:

GET /todos/<id>/details

Is this possible with codable routes? Or do I have to go back to the old routing version?


Solution

  • Unfortunately, this is not yet possible with Kitura's Codable routes - as you identified, only a trailing :id is supported.

    Being able to move the single :id parameter elsewhere within the path might be possible in a relatively small patch. Supporting multiple path parameters would be significantly more complex: Codable routing would need to call your route handler with the right number of (individually typed) parameters. Perhaps there's a half-way house where we could support an array of path parameters (all of a single type).

    If you'd like to raise an issue against Kitura and elaborate on your use cases, we could discuss possible solutions and whether they could reduce the need to fall back to 'traditional' routing.