I wonder how to bind RequestReader and Route together in Finch. I didnt find a complete example about it.
This example is coming from finch github, and it is working properly.
import io.finch.route._
import com.twitter.finagle.Httpx
val api: Router[String] = get("hello") { "Hello, World!" }
Httpx.serve(":3000", api.toService)
I understand that this code will get path "hello" and will return the response "hello world"
and then I want to bind RequestHeader to it.
val doSomethingWithRequest: RequestReader[String] =
for {
foo <- param("foo")
bar <- param("bar")
} yield "u got me"
val api: Router[RequestReader[String]] = Get / "hello" /> doSomethingWithRequest
val server = Httpx.serve(":3000", api.toService)
I thought this code means if the url is given "http://localhost:3000/hello?foo=3" it will return the response "u got me". However, the response status is 404.
I think I did something wrong for the combination between Route and RequestHeader.
Maybe someone can help me on this one, also, it would be better to share some good doc about this Finch. the version is bumping up so frequently and the doc is outdated https://finagle.github.io/blog/2014/12/10/rest-apis-with-finch/