I am using com.twitter.finatra.http.Controller
to set up endpoints in Scala and I have an endpoint like this:
get(s"${endpoint}/:id/lookup/?") {request: Request =>
println("here")
val id = request.params("id")
response.ok
}
It is my understanding that it should match the link http://myservice/123/lookup
and request.params("id")
should return "123". But it never gets to println. However when I try http://myservice/:id/lookup
(exactly like that) - it does. So it's expecting exactly ":id" in the address rather than a dynamic value. And obviously request.params("id")
is not there. If I call http://myservice/:id/lookup?id=123
, then request.params("id")
is 123
coming from the query string parameter
What am doing wrong or misunderstanding? I am very new to Scala, so it's entirely possible that the whole thing is set up not how it is supposed to.