Skip to content
A STTP backend that utilizes Monix Observables and Tasks.
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
project
src/main/scala/com/fullfacing/backend
.gitignore
LICENSE
README.md
build.sbt
sonatype.sbt

README.md

CircleCI Maven Central

akkaMonixSttpBackend

Introduction:
akkaMonixSttpBackend is a backend for sttp using Akka-HTTP to handle requests, and with Task as the response Monad and Observable as the streaming type. It is a modification of the Akka-HTTP backend provided by sttp, with instances of Futures deferred to Tasks and Akka-Streams Sources converted to Observables.

The motivation behind creating this backend as opposed to using the existing Monix wrapped async-http-client backend is to give an alternative for projects that already have Akka-HTTP as a dependency, removing the need for the async-http-client dependency as well.

Installation:
Add the following sbt dependency:
"com.fullfacing" %% "sttp-akka-monix" % "1.0.1"

Usage:
Usage is identical to the Akka-HTTP backend with only the response type differing:

import akka.util.ByteString
import com.fullfacing.backend.AkkaMonixHttpBackend
import com.softwaremill.sttp.{Response, SttpBackend, _}
import monix.eval.Task
import monix.reactive.Observable

implicit val backend: SttpBackend[Task, Observable[ByteString]] = AkkaMonixHttpBackend()

// To set the request body as a stream:
val observable: Observable[ByteString] = ???

sttp
  .streamBody(observable)
  .post(uri"...")
  .send()

// To receive the response body as a stream:
val response: Task[Response[Observable[ByteString]]] =
  sttp
    .post(uri"...")
    .response(asStream[Observable[ByteString]])
    .send()
You can’t perform that action at this time.