com-lihaoyi/cask

Path with different query parameters should be considered unique

Opened this issue · 0 comments

The overloading based on query parameters is inconsistent. When checking routes for overlaps, the parameters are ignored, yet when serving the requests, the overloads are selected based on them.

Following routes are rejected as invalid.

  @cask.get("/hello")
  def hello() = {
    "Hello World!"
  }

  @cask.get("/hello")
  def helloName(name: String) = {
    s"Hello ${name.reverse}"
  }

The error is:

More than one endpoint has the same path: get /hello, get /hello

However when I remove the helloName parameter, requests with the query parameter name are not served.

I suggest query parameters are considered similar to path segments, as following similar routes are valid:

  @cask.get("/hello")
  def hello() = {
    "Hello World!"
  }

  @cask.get("/hello/:name")
  def helloName(name: String) = {
    s"Hello ${name.reverse}"
  }