I'm implementing simple HTTP routing server that needs to analyze few fields in incoming request and resend it to internal server, then it should return reply to the caller as it is. I also want to log time spent waiting for reply from internal server. My directive looks like this

complete {

  val pipeline: HttpRequest => Future[String] = sendReceive ~> unmarshal[String]
  val response: Future[String] = pipeline(Post("https://my_internal_serverservices/MainService", payload.toString()))
  response

}

But this works only for HTTP 200 replies. For other return codes future never completes.

Could you please demonstrate how to implement this properly ? Ideally I'd like to route requests in original state - with all http headers and etc.

有帮助吗?

解决方案

As Rudolph pointed out the problem was in use of unmarshal.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top