Here is what I am trying to do
package gc.services.http.playWs.lmi
import com.softwaremill.macwire.Macwire
import play.api.Play.current
import play.api.libs.ws._
import play.api.libs.ws.ning.NingAsyncHttpClientConfigBuilder
import scala.concurrent.Future
import play.api.libs.ws.{WSResponse, WSRequestHolder, WSClient}
import scala.concurrent.Future
class LmiWs extends Macwire{
val baseUrl = "http://api.lmiforall.org.uk/api/v1"
//inject plays ws client
lazy val http = wire[WSClient]
def getRequestHolder(url: String = baseUrl): WSRequestHolder = {
http.url(url)
}
def get(request: WSRequestHolder): Future[WSResponse] = {
request.get()
}
}
If I try wire[WS] IntelliJ gives cannot resolve symbol. There are no errors shown in IntelliJ with the above but at compilation mac wire throws
annot find constructor for WeakTypeTag[play.api.libs.ws.WSClient]
This class is just to define the base route for the app I want to hit, and it will be extended by some different classes for each particular route. I want to be able to mock the WS dependency so that when I test this and the descendant classes I can do so without sending an actual HTTP request.
也许你可以试试这个:
lazy val http: WSClient = WS.client
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.