I've been running into issues refactoring common code out of the 3 methods and into makeRequest() but I get ambiguous implicit matching from the compiler. I am not sure if this is from having defaults for the implicit methods or some other issue but my goal is for getRequest/deleteRequest/postRequest can simply call makeRequest("GET")/makeRequest("DELETE")/makeRequest("POST"). Previously none of the parameters were implicit, I'm just attempting to reach the goal by using implicits
def makeRequest(method: String)(implicit path: String, base: String, params: Seq[(String, String)], body: Option[String], retriesLeft: Int): Future[WSResponse] = ???
def getRequest()(implicit path: String, base: String = baseUrl, params: Seq[(String, String)] = Seq(), body: Option[String] = None, retriesLeft: Int = retries): Future[WSResponse] = makeRequest("GET")
def deleteRequest()(implicit path: String, base: String = baseUrl, params: Seq[(String, String)] = Seq(), body: Option[String] = None, retriesLeft: Int = retries): Future[WSResponse] = makeRequest("GET")
def postRequest[T]()(path: String, body: T, base: String = baseUrl, params: Seq[(String, String)] = Seq(), retriesLeft: Int = retries)
(implicit wrt: play.api.http.Writeable[T], ct : play.api.http.ContentTypeOf[T]): Future[WSResponse] = makeRequest("POST")
I get this and same with deleteRequest
ambiguous implicit values:
[error] both value base of type String
[error] and value path of type String
[error] match expected type String
[error] def getRequest()(implicit path: String, base: String = baseUrl, params: Seq[(String, String)] = Seq(), body: Option[String] = None, retriesLeft: Int = retries): Future[WSResponse] = makeRequest("GET")
implicitforString- you should as much as possible avoid defining implicits for common types... That said, to debug ambiguous implicits, you need to look at the call sites of the above methods and find all the implicits in scope, so the information you've provided us isn't enough.Stringwill not work as expected.makeRequest("GET")be not possible?