已经为此工作了几天,但仍然不知道发生了什么:有一个 finch Web 服务,build.sbt 依赖项如下所示:
"com.github.finagle" %% "finch-circe" % finchVersion changing(),
"com.github.finagle" %% "finch-core" % finchVersion changing(),
"com.github.finagle" %% "finch-jackson" % finchVersion changing(),
"com.github.finagle" %% "finch-test" % finchVersion changing(),
"com.twitter" %% "twitter-server" % "1.28.0",
雀版本是 0.14.0。端点看起来像:
def makeService(statsReceiver: StatsReceiver): Service[Request, Response] = {
//val getUserCounter = statsReceiver.counter("get_user_counter")
(
MyEndpoint.endpoint1()
:+: SomeEndpoint.deleteEntity()
:+: SomeEndpoint.createEntity()
:+: SomeEndpoint.updateEntity()
) handle {
case e: InvalidClientError => Unauthorized(e)
case e: InvalidContextError => BadRequest(e)
case e: RelevanceError => BadRequest(e)
case e: Exception => InternalServerError(e)
} toService
我在“toService”行收到错误消息,例如:
[error] /workplace/relevance-service/src/main/scala/com/company/service/endpoint/serviceEndpoints.scala:39: An Endpoint you're trying to convert into a Finagle service is missing one or more encoders.
[error]
[error] Make sure Exception is one of the following:
[error]
[error] * A com.twitter.finagle.http.Response
[error] * A value of a type with an io.finch.Encode instance (with the corresponding content-type)
[error] * A coproduct made up of some combination of the above
[error]
并尝试了以下几行:
import io.finch.circe._
首先,这个 io.finch.circe._ 没有在代码中使用,因为它在 IDE 中是灰色的。而且我仍然遇到相同的构建错误。我完全迷失在这里。任何人都可以帮我解决我在这里想念的东西吗?google/bing 并没有给我任何非常有用的东西。
谢谢。