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.

43 lines
894 B

4 years ago
4 years ago
4 years ago
4 years ago
  1. package nova.monadic_sfx.http.requests
  2. import nova.monadic_sfx.AppTypes
  3. import nova.monadic_sfx.AppTypes.HttpBackend
  4. import monix.eval.Task
  5. import sttp.client._
  6. import sttp.client.circe._
  7. import io.circe.generic.auto._
  8. import nova.monadic_sfx.models._
  9. import cats.data.EitherT
  10. class DummyRequest(backend: HttpBackend) extends AppTypes {
  11. private implicit val _backend = backend
  12. def send() = {
  13. Task
  14. .suspend {
  15. for {
  16. req <-
  17. basicRequest
  18. .get(uri"https://httpbin.org/get")
  19. .response(asJson[HttpBinResponse])
  20. .send()
  21. } yield (req)
  22. }
  23. }
  24. def test() = {
  25. for {
  26. res <- send()
  27. res3 <- Task { res.body }
  28. res2 <- Task {
  29. res3.fold(
  30. err => {
  31. err.toString()
  32. },
  33. value => value.toString()
  34. )
  35. }
  36. } yield (res3)
  37. }
  38. }