Hello.
I am using Finch (finchx-*) and all is fine, but I have encountered some strange(for me) situation.
This code works well:
val fetch: Endpoint[IO, Seq[Agent]] = get("path") {
fetchAll[Agent] match {
case Left(error) => checkError(error)
case Right(data) => Ok(data)
}
} handle {
case e: Exception => BadRequest(e)
}
But this one not:
def fetch[T : ClassTag](path: String): Endpoint[IO, Seq[T]] = get(path) {
fetchAll[T] match {
case Left(error) => checkError(error)
case Right(data) => Ok(data)
}
} handle {
case e: Exception => BadRequest(e)
}
With error:
[error] /home/laniakea/projects/bridgeight/src/main/scala/com/bridgeight/Api.scala:36:69: type mismatch;
[error] found : String
[error] required: io.finch.Endpoint[cats.effect.IO,?]
[error] def fetch[T : ClassTag](path: String): Endpoint[IO, Seq[T]] = get(path) {
In both cases IDEA said nothing. I understand that there is something with implicit conversion from String
to Endpoint[F, A]
, but why it works in first case, but not in the second?
Imports:
import cats.effect.{ContextShift, IO}
import com.bridgeight.entities.models.Location
import com.bridgeight.entities.models.classifiers.Agent
import com.twitter.finagle.Service
import com.twitter.finagle.http.{Request, Response}
import io.circe.generic.auto._
import io.finch._
import io.finch.circe._
import scala.reflect.ClassTag
Thank you.