This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client3.examples | |
import monix.eval.Task | |
import sttp.capabilities.WebSockets | |
import sttp.capabilities.monix.MonixStreams | |
import sttp.client3._ | |
import sttp.client3.asynchttpclient.monix.AsyncHttpClientMonixBackend | |
import sttp.client3.testing.SttpBackendStub | |
import sttp.model.StatusCode | |
import sttp.ws.{WebSocket, WebSocketFrame} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client3.examples | |
import io.circe.generic.auto._ | |
import sttp.client3._ | |
import sttp.client3.asynchttpclient.monix.AsyncHttpClientMonixBackend | |
import sttp.client3.circe._ | |
object GetAndParseJsonGetRightMonixCirce extends App { | |
import monix.execution.Scheduler.Implicits.global |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client3.examples | |
import io.circe | |
import io.circe.generic.auto._ | |
import sttp.client3._ | |
import sttp.client3.circe._ | |
object GetRawRequestBodySynchronous extends App { | |
case class HttpBinResponse(origin: String, headers: Map[String, String]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client3.examples | |
import sttp.capabilities.zio.ZioStreams | |
import sttp.client3._ | |
import sttp.client3.asynchttpclient.zio.{AsyncHttpClientZioBackend, SttpClient} | |
import zio._ | |
import zio.console._ | |
import zio.stream._ | |
object StreamZio extends App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client3.examples | |
import cats.effect.{ContextShift, IO} | |
import fs2._ | |
import sttp.capabilities.fs2.Fs2Streams | |
import sttp.client3._ | |
import sttp.client3.asynchttpclient.fs2.AsyncHttpClientFs2Backend | |
import sttp.ws.WebSocketFrame | |
object WebSocketStreamFs2 extends App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client3.examples | |
import sttp.client3._ | |
import sttp.client3.akkahttp.AkkaHttpBackend | |
import sttp.ws.WebSocket | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
object WebSocketAkka extends App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client.examples | |
import sttp.client._ | |
import sttp.client.asynchttpclient.fs2.AsyncHttpClientFs2Backend | |
import cats.effect.{ContextShift, IO} | |
import cats.instances.string._ | |
import fs2.{Stream, text} | |
import sttp.capabilities.fs2.Fs2Streams | |
object StreamFs2 extends App { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait SttpBackend[F[_], +P] { | |
def send[T, R >: P with Effect[F]](request: Request[T, R]): F[Response[T]] | |
def close(): F[Unit] | |
def responseMonad: MonadError[F] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sttp.client.examples | |
import monix.eval.Task | |
import sttp.client._ | |
import sttp.client.asynchttpclient.monix.AsyncHttpClientMonixBackend | |
import sttp.ws.WebSocket | |
object WebSocketMonix extends App { | |
import monix.execution.Scheduler.Implicits.global |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zio._ | |
object Main extends App { | |
override def run(args: List[String]): ZIO[zio.ZEnv, Nothing, ExitCode] = { | |
// instead of a method accessor, explicitly accessing the environment | |
val program: ZIO[Has[UserRegistration], Throwable, User] = | |
ZIO.accessM[Has[UserRegistration]](_.get.register(User("adam", "adam@hello.com"))) | |
// the DB service is created using through layers (which wrap managed resources) | |
val dbLayer: ZLayer[Any, Throwable, DB] = |