【问题标题】:Server.route does not conform to the expected type requestcontext [Akka,Scala]Server.route 不符合预期类型 requestcontext [Akka,Scala]
【发布时间】:2017-05-04 22:06:00
【问题描述】:

我正在尝试使用这个示例http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-M2/scala/http/directives/coding-directives/decodeRequest.html

1 def routesWithCompression = {


2   time() {
3     count() {
4       decodeRequest(Gzip) {

5            entity(as[String]) { content: String =>
6              complete(s"Request content: '$content'")
7          }
8          }

9       }
10      }
11 }

我在第 8 行得到编译错误说明

server.route 类型的表达式不符合 requestcontext

老实说,我不知道哪个需要 RequestContext 作为输入,以及如何将 server.route 转换为 RequestContext 类型。

谢谢

【问题讨论】:

    标签: scala akka akka-http


    【解决方案1】:

    这是一个过时的实验版本。如果您使用的是更新版本的 Akka Streams/HTTP,那么旧代码很有可能无法编译或运行。您可能想查看最新的 Akka-HTTP encoding/decoding example

    【讨论】:

    • 我很抱歉,文档链接是旧的,但我使用的是当前的 API,它有 decodeRequest() 和 encodeResponse() 。我认为那里没有错。谢谢
    猜你喜欢
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    • 1970-01-01
    • 1970-01-01
    • 2017-04-13
    • 1970-01-01
    • 2018-07-20
    相关资源
    最近更新 更多