You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
46 lines
1.1 KiB
package wow.doge.chatto.service
|
|
|
|
import scala.concurrent.ExecutionContext
|
|
import scala.concurrent.ExecutionContext.Implicits.global
|
|
import scala.async.Async.{async, await}
|
|
import sttp.client.json4s._
|
|
import org.json4s._
|
|
import sttp.client._
|
|
import scala.concurrent.Future
|
|
import sttp.client.asynchttpclient.WebSocketHandler
|
|
import javax.inject.Inject
|
|
import scala.async.Async.{async, await}
|
|
import scala.util.Success
|
|
import scala.util.Failure
|
|
import wow.doge.chatto.AppData
|
|
import wow.doge.chatto.types.AppTypes.HttpBackend
|
|
|
|
class UserService @Inject() (appData: AppData)(
|
|
implicit backend: HttpBackend
|
|
) {
|
|
private implicit lazy val serialization = org.json4s.native.Serialization
|
|
|
|
def func1() = {
|
|
val willBeResponse = basicRequest
|
|
.get(uri"https://httpbin.org/get")
|
|
.response(asJson[HttpBinResponse])
|
|
.send()
|
|
async {
|
|
val r = await { willBeResponse }
|
|
r.body.map(println)
|
|
}
|
|
}
|
|
|
|
def func2() =
|
|
basicRequest
|
|
.get(uri"https://httpbin.org/get")
|
|
.response(asJson[HttpBinResponse])
|
|
.send()
|
|
|
|
}
|
|
|
|
case class HttpBinResponse(
|
|
url: String,
|
|
origin: String,
|
|
headers: Map[String, String]
|
|
)
|