tpetillot on better-close-for-tw
Complete bootstrap rework Modi… (compare)
Future
and F[_]
(or finchx)
I can't get either to work. i.e. my options are coming back as null still
e.g.
import io.finch.circe.dropNullValues._
val videoCanned: Endpoint[IO, Video] = get(videoadmin :: "canned") {
Ok(Video(9999,"canned","url","link", description = "canned"))
}
But the optional null fields still come back as :null
What am I doing wrong?
Thanks
Ah, got it working, just had to be careful with imports
https://gist.github.com/fancellu/b145ed3a0a27c6a1c414c0d485a44d37
private def foo: Endpoint[IO, String] = get(path("debug")) {
None.getOrElse(return BadRequest(???))
Ok("test")
}
return
will return the outer function (thus BadRequest(???)
is expected to be of type Endpoint[IO, String]
)
get(...)
"(GET /help :+: (POST /archive :: build-light :+: (POST /archive :: build :+: (POST /fact :: add :: body :+: (GET /fact :: list :+: (GET /scroll :: list :+: (POST /scroll :: apply :: body :+: GET /debug :: situationtheory :: print)))))))"
GET /help
is a single endpoint
I'm using finchx 0.32.1. I wrote below code, but unable to understand the reason for compilation error : "Cannot resolve overloaded method"
Can anyone please help me understand? Appreciate the help.
private val greetByName : Endpoint[IO, Json] = get(path("hello") :: paramOption("name")) = {
Ok("Hello".asJson)
}
paramOption
which means the mapper is going to want an argument to the function you are using for mapping. something like this might be what you are looking for: private val greetByName: Endpoint[IO, Json] = get(path("hello") :: paramOption("name"))({ name: Option[String] =>
Ok("Hello".asJson)
})
jsonBody
and decoding via Circe, and I don’t seem to be able to catch the decoding error if it occurs- I want to be able to return a 400 response when bad json is submitted, but the circe DecodingFailure
is wrapped in a finch-private CirceError
case class. Is there a better approach to achieve this end?