Frage

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.

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top