It seems like I don't fully understand how TypeTags and ClassTags work. I'm trying to create generic function that makes http REST call using Spray. It looks like this
def sendRequest[RQ, RS](userId: String, endPoint: String, body: RQ): Future[RS] = {
val pipeline =
sendReceive ~>
decode(Gzip) ~>
decode(Deflate) ~>
unmarshal[RS]
pipeline(Post("http://something", body))
}
which I attempt to use like this
val result: Future[FetchStreamsResponse] = sendRequest(userId, "v1/get_streams", body)
It gave Error:(161, 18) could not find implicit value for evidence parameter of type spray.httpx.unmarshalling.FromResponseUnmarshaller[RS] unmarshal[RS]
of course. I tried specifying type as RS : ClassTag : TypeTag
but it didn't help. Does use of class tag requires modification of unmarshal
function too ? What shall I do ?
Aucun commentaire:
Enregistrer un commentaire