从发帖请求获取标题-Finch(Finagle)

时间:2018-06-27 13:16:24

标签: scala post http-headers finagle

这是我的代码:

post((name :: stringBody) :+: headerOption[String]("AMI-WS-Header")) { (body: String, amiHeader: String) =>
  val response: HttpResponse[String] = Http(url + name).headers(
    if (name == "login") Map("Content-Type" -> "application/json")
    else Map("Content-Type" -> "application/json", "AMI-WS-Header" -> amiHeader)
  ).postData(body).asString
  Ok(parse(response body).right.get)

如您所见,我正在尝试获取特定的标头以及请求的正文。但是,它给了我以下错误:

Error:(32, 9) overloaded method value apply with alternatives:
  (input: io.finch.Input)io.finch.Endpoint.Result[String :+: Option[String] :+: shapeless.CNil] <and>
  (mapper: io.finch.syntax.Mapper[String :+: Option[String] :+: shapeless.CNil])io.finch.Endpoint[mapper.Out]
  cannot be applied to ((String, String) => io.finch.Output[io.circe.Json])
  post((name :: stringBody) :+: headerOption("AMI-WS-Header")) { (body: String, amiHeader: String) =>

我已经搜索了很多解决方案,但到目前为止还没有发现任何问题。

从发布请求中获取特定标头值的正确方法是什么?

0 个答案:

没有答案