문제

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