Hi! I have a question about the routing. I want ...
# ktor
c
Hi! I have a question about the routing. I want to achieve something similar to
Copy code
routing {
  route("/accounts") {
    param("name") {
      get {
        findAccountsByName(...)
      }
  }
  get {
    findAllAccounts()
  }
}
so that a GET /accounts?name=me would execute findAccountsByName(...) and GET /accounts would execute findAllAccounts() Apparently it always executes findAllAccounts(). Any idea why?
s
Theres also
optionalParam
c
Thanks 🙂 Tried out some things and finally got it working with
Copy code
method(Get) {
  route("/accounts") {
    param("name") {
      handle {
        findAccountsByName(...)
      }
    }
    handle {
      findAllAccounts()
    }
  }
}