aboutsummaryrefslogtreecommitdiff
path: root/docs/backends/akkahttp.rst
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-10-12 19:23:09 +0200
committeradamw <adam@warski.org>2017-10-12 19:23:09 +0200
commit7bf4d02da823c21b27cf20ba0b764b511ac69432 (patch)
tree04b9ab557c4af82b9970af386e6f4f9e4292e472 /docs/backends/akkahttp.rst
parent7885188a982c193e26f8ca6bc9aea8f6a642b32d (diff)
downloadsttp-7bf4d02da823c21b27cf20ba0b764b511ac69432.tar.gz
sttp-7bf4d02da823c21b27cf20ba0b764b511ac69432.tar.bz2
sttp-7bf4d02da823c21b27cf20ba0b764b511ac69432.zip
More docs
Diffstat (limited to 'docs/backends/akkahttp.rst')
-rw-r--r--docs/backends/akkahttp.rst52
1 files changed, 52 insertions, 0 deletions
diff --git a/docs/backends/akkahttp.rst b/docs/backends/akkahttp.rst
new file mode 100644
index 0000000..41e3a7c
--- /dev/null
+++ b/docs/backends/akkahttp.rst
@@ -0,0 +1,52 @@
+``AkkaHttpBackend``
+===================
+
+To use, add the following dependency to your project::
+
+ "com.softwaremill.sttp" %% "akka-http-backend" % "0.0.20"
+
+This backend depends on `akka-http <http://doc.akka.io/docs/akka-http/current/scala/http/>`_.
+A fully **asynchronous** backend. Sending a request returns a response wrapped
+in a ``Future``.
+
+Next you'll need to add an implicit value::
+
+ implicit val sttpBackend = AkkaHttpBackend()
+
+ // or, if you'd like to use an existing actor system:
+ implicit val sttpBackend = AkkaHttpBackend.usingActorSystem(actorSystem)
+
+This backend supports sending and receiving
+`akka-streams <http://doc.akka.io/docs/akka/current/scala/stream/index.html>`_
+streams of type ``akka.stream.scaladsl.Source[ByteString, Any]``.
+
+To set the request body as a stream::
+
+ import com.softwaremill.sttp._
+ import com.softwaremill.sttp.akkahttp._
+
+ import akka.stream.scaladsl.Source
+ import akka.util.ByteString
+
+ val source: Source[ByteString, Any] = ...
+
+ sttp
+ .streamBody(source)
+ .post(uri"...")
+
+To receive the response body as a stream::
+
+ import com.softwaremill.sttp._
+ import com.softwaremill.sttp.akkahttp._
+
+ import akka.stream.scaladsl.Source
+ import akka.util.ByteString
+
+ implicit val sttpBackend = AkkaHttpBackend()
+
+ val response: Future[Response[Source[ByteString, Any]]] =
+ sttp
+ .post(uri"...")
+ .response(asStream[Source[ByteString, Any]])
+ .send()
+