【问题标题】:How to do a generic response for akka-http如何对 akka-http 进行通用响应
【发布时间】:2018-12-28 04:28:06
【问题描述】:

我需要创建一个函数来评估给定 Future[Either[Error, T]] 的 Route 我是这样做的

def handleFuture[T] handleFuture(f: Future[Either[Error, T]]): Route = {
  onComplete(f) {
    case Failure(er) => complete(InternalServerError, err)
    case Success(Left(er)) => complete(BadRequest, er)
    case Success(Right(value)) => complete(OK, value)
  }
}

我在泛型类型A 的范围内有隐式编组器/解组器,我收到too many arguments for method complete 错误。

我做错了什么?

【问题讨论】:

    标签: scala akka-http


    【解决方案1】:

    你有一个错字。将err 更改为er

    case Failure(er) => complete(InternalServerError, er)
                                                   // ^
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-29
      相关资源
      最近更新 更多