3

I had this:

class RichResponse(future: Future[WSResponse]) {

  def failIfNot(statuses: Int*)(implicit executor: ExecutionContext) = {
    future.map { response =>
      if(statuses.contains(response.status)) {
        response
      } else {
        throw new RuntimeException("Bad HTTP response for %s: %s".format(
          response.ahcResponse.getUri, response.status))
      }
    }
  }

}

object Implicits {

  implicit def responseToRichResponse(future: Future[WSResponse]) = new RichResponse(future)

}

The usage was like this:

WS.url("http://stackoverflow.com/questions/ask").failIfNot(OK)

But after upgrading from 2.1 to 2.3, achResponse is no longer present. How to can I get the underlying (and more complete) response object?

Paul Draper
  • 78,542
  • 46
  • 206
  • 285

1 Answers1

1

I started reading the source, an it appears that

response.underlying[NingWSResponse].ahcResponse

would be the new way to do this.

Doesn't seem very typesafe....

Paul Draper
  • 78,542
  • 46
  • 206
  • 285