hmrc / http-verbs

Library which encapsulates common concerns for calling other HTTP services
Apache License 2.0
15 stars 42 forks source link

play deprecations #60

Open pawelpanasewicz opened 7 years ago

pawelpanasewicz commented 7 years ago

WSRequest.scala:44 (and possible other code) relies on deprecations in play.

As a result it's not possible to run parts of the code without running Play Appliacion. Isolation and Encapsulation is broken.

Example. Below code throws Exception in thread "main" java.lang.RuntimeException: There is no started application

object Demo extends App {
  val ws = new uk.gov.hmrc.play.http.ws.WSHttp {
    override val hooks: Seq[HttpHook] = Nil
  }
  implicit val hc = HeaderCarrier()

  ws.GET[HttpResponse]("https://google.com") //BOOM
}
Exception in thread "main" java.lang.RuntimeException: There is no started application
    at scala.sys.package$.error(package.scala:27)
    at play.api.Play$$anonfun$current$1.apply(Play.scala:86)
    at play.api.Play$$anonfun$current$1.apply(Play.scala:86)
    at scala.Option.getOrElse(Option.scala:121)
    at play.api.Play$.current(Play.scala:86)
    at uk.gov.hmrc.play.http.ws.WSRequest$class.buildRequest(WSRequest.scala:44)
...
pawelpanasewicz commented 7 years ago

https://www.playframework.com/documentation/2.5.x/ScalaWS#Directly-creating-WSClient