Skip to content

Commit

Permalink
Release 3.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski committed Aug 9, 2023
1 parent 15d710d commit edc11d1
Show file tree
Hide file tree
Showing 24 changed files with 219 additions and 96 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ sttp (v2) documentation is available at [sttp.softwaremill.com/en/v2](http://stt

sttp (v1) documentation is available at [sttp.softwaremill.com/en/v1](https://sttp.softwaremill.com/en/v1).

scaladoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client3/core_2.12/3.8.16)
scaladoc is available at [https://www.javadoc.io](https://www.javadoc.io/doc/com.softwaremill.sttp.client3/core_2.12/3.9.0)

## Quickstart with Ammonite

If you are an [Ammonite](http://ammonite.io) user, you can quickly start experimenting with sttp by copy-pasting the following:

```scala
import $ivy.`com.softwaremill.sttp.client3::core:3.8.16`
import $ivy.`com.softwaremill.sttp.client3::core:3.9.0`
import sttp.client3.quick._
quickRequest.get(uri"http://httpbin.org/ip").send(backend)
```
Expand All @@ -68,7 +68,7 @@ This brings in the sttp API and a synchronous backend instance.
Add the following dependency:

```scala
"com.softwaremill.sttp.client3" %% "core" % "3.8.16"
"com.softwaremill.sttp.client3" %% "core" % "3.9.0"
```

Then, import:
Expand Down Expand Up @@ -123,7 +123,7 @@ The documentation is typechecked using [mdoc](https://scalameta.org/mdoc/). The

When generating documentation, it's best to set the version to the current one, so that the generated doc files don't include modifications with the current snapshot version.

That is, in sbt run: `set version := "3.8.16"`, before running `mdoc` in `docs`.
That is, in sbt run: `set version := "3.9.0"`, before running `mdoc` in `docs`.

### Testing the Scala.JS backend

Expand Down
2 changes: 1 addition & 1 deletion generated-docs/out/backends/akka.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This backend is based on [akka-http](http://doc.akka.io/docs/akka-http/current/scala/http/). To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.8.16"
"com.softwaremill.sttp.client3" %% "akka-http-backend" % "3.9.0"
```

A fully **asynchronous** backend. Uses the `Future` effect to return responses. There are also [other `Future`-based backends](future.md), which don't depend on Akka.
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/backends/catseffect.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ Creation of the backend can be done in two basic ways:
Firstly, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "armeria-backend-cats" % "3.8.16" // for cats-effect 3.x
"com.softwaremill.sttp.client3" %% "armeria-backend-cats" % "3.9.0" // for cats-effect 3.x
// or
"com.softwaremill.sttp.client3" %% "armeria-backend-cats-ce2" % "3.8.16" // for cats-effect 2.x
"com.softwaremill.sttp.client3" %% "armeria-backend-cats-ce2" % "3.9.0" // for cats-effect 2.x
```

create client:
Expand Down
2 changes: 1 addition & 1 deletion generated-docs/out/backends/finagle.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "finagle-backend" % "3.8.16"
"com.softwaremill.sttp.client3" %% "finagle-backend" % "3.9.0"
```

Next you'll need to add an implicit value:
Expand Down
8 changes: 4 additions & 4 deletions generated-docs/out/backends/fs2.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Creation of the backend can be done in two basic ways:
Firstly, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "fs2" % "3.8.16" // for cats-effect 3.x & fs2 3.x
"com.softwaremill.sttp.client3" %% "fs2" % "3.9.0" // for cats-effect 3.x & fs2 3.x
// or
"com.softwaremill.sttp.client3" %% "fs2-ce2" % "3.8.16" // for cats-effect 2.x & fs2 2.x
"com.softwaremill.sttp.client3" %% "fs2-ce2" % "3.9.0" // for cats-effect 2.x & fs2 2.x
```

Obtain a cats-effect `Resource` which creates the backend, and closes the thread pool after the resource is no longer used:
Expand Down Expand Up @@ -78,9 +78,9 @@ Host header override is supported in environments running Java 12 onwards, but i
To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.8.16" // for cats-effect 3.x & fs2 3.x
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.9.0" // for cats-effect 3.x & fs2 3.x
// or
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.8.16" // for cats-effect 2.x & fs2 2.x
"com.softwaremill.sttp.client3" %% "armeria-backend-fs2" % "3.9.0" // for cats-effect 2.x & fs2 2.x
```

create client:
Expand Down
6 changes: 3 additions & 3 deletions generated-docs/out/backends/future.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Class Supported stream type
To use, you don't need any extra dependencies, `core` is enough:

```
"com.softwaremill.sttp.client3" %% "core" % "3.8.16"
"com.softwaremill.sttp.client3" %% "core" % "3.9.0"
```

You'll need the following imports:
Expand Down Expand Up @@ -59,7 +59,7 @@ Host header override is supported in environments running Java 12 onwards, but i
To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.8.16"
"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.9.0"
```

and some imports:
Expand Down Expand Up @@ -91,7 +91,7 @@ This backend depends on [OkHttp](http://square.github.io/okhttp/) and fully supp
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "armeria-backend" % "3.8.16"
"com.softwaremill.sttp.client3" %% "armeria-backend" % "3.9.0"
```

add imports:
Expand Down
4 changes: 2 additions & 2 deletions generated-docs/out/backends/http4s.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
This backend is based on [http4s](https://http4s.org) (client) and is **asynchronous**. To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "http4s-backend" % "3.8.16" // for cats-effect 3.x & http4s 1.0.0-Mx
"com.softwaremill.sttp.client3" %% "http4s-backend" % "3.9.0" // for cats-effect 3.x & http4s 1.0.0-Mx
// or
"com.softwaremill.sttp.client3" %% "http4s-ce2-backend" % "3.8.16" // for cats-effect 2.x & http4s 0.21.x
"com.softwaremill.sttp.client3" %% "http4s-ce2-backend" % "3.9.0" // for cats-effect 2.x & http4s 0.21.x
```

The backend can be created in a couple of ways, e.g.:
Expand Down
12 changes: 6 additions & 6 deletions generated-docs/out/backends/javascript/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A JavaScript backend with web socket support. Implemented using the [Fetch API](
This is the default backend, available in the main jar for JS. To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %%% "core" % "3.8.16"
"com.softwaremill.sttp.client3" %%% "core" % "3.9.0"
```

And create the backend instance:
Expand All @@ -26,7 +26,7 @@ Note that `Fetch` does not pass cookies by default. If your request needs cookie
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %%% "monix" % "3.8.16"
"com.softwaremill.sttp.client3" %%% "monix" % "3.9.0"
```

And create the backend instance:
Expand All @@ -40,7 +40,7 @@ val backend = FetchMonixBackend()
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %%% "zio" % "3.8.16"
"com.softwaremill.sttp.client3" %%% "zio" % "3.9.0"
```

And create the backend instance:
Expand All @@ -55,13 +55,13 @@ Any effect implementing the cats-effect `Concurrent` typeclass can be used. To u
your project:

```
"com.softwaremill.sttp.client3" %%% "cats" % "3.8.16"
"com.softwaremill.sttp.client3" %%% "cats" % "3.9.0"
```

If you are on Cats Effect 2 (CE2) you will need to add the CE2 specific dependency instead:

```
"com.softwaremill.sttp.client3" %%% "catsce2 % "3.8.16"
"com.softwaremill.sttp.client3" %%% "catsce2 % "3.9.0"
```

And create the backend instance:
Expand Down Expand Up @@ -129,7 +129,7 @@ Streaming support is provided via `FetchMonixBackend`. Note that streaming suppo
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %%% "monix" % "3.8.16"
"com.softwaremill.sttp.client3" %%% "monix" % "3.9.0"
```

An example of streaming a response:
Expand Down
6 changes: 3 additions & 3 deletions generated-docs/out/backends/monix.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Creation of the backend can be done in two basic ways:
Firstly, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "monix" % "3.8.16"
"com.softwaremill.sttp.client3" %% "monix" % "3.9.0"
```

and create the backend using:
Expand Down Expand Up @@ -50,7 +50,7 @@ Host header override is supported in environments running Java 12 onwards, but i
To use, add the following dependency to your project:

```scala
"com.softwaremill.sttp.client3" %% "okhttp-backend-monix" % "3.8.16"
"com.softwaremill.sttp.client3" %% "okhttp-backend-monix" % "3.9.0"
```

Create the backend using:
Expand All @@ -76,7 +76,7 @@ This backend depends on [OkHttp](http://square.github.io/okhttp/) and fully supp
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "armeria-backend-monix" % "3.8.16"
"com.softwaremill.sttp.client3" %% "armeria-backend-monix" % "3.9.0"
```

add imports:
Expand Down
2 changes: 1 addition & 1 deletion generated-docs/out/backends/native/curl.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A Scala Native backend implemented using [Curl](https://github.com/curl/curl/blo
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %%% "core" % "3.8.16"
"com.softwaremill.sttp.client3" %%% "core" % "3.9.0"
```

and initialize one of the backends:
Expand Down
123 changes: 123 additions & 0 deletions generated-docs/out/backends/pekko.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Pekko backend

This backend is based on [pekko-http](https://pekko.apache.org/docs/pekko-http/current/). To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "pekko-http-backend" % "3.9.0"
```

A fully **asynchronous** backend. Uses the `Future` effect to return responses. There are also [other `Future`-based backends](future.md), which don't depend on Pekko.

Note that you'll also need an explicit dependency on pekko-streams, as pekko-http doesn't depend on any specific pekko-streams version. So you'll also need to add, for example:

```
"org.apache.pekko" %% "pekko-stream" % "1.0.1"
```

Next you'll need to add create the backend instance:

```scala
import sttp.client3.pekkohttp._
val backend = PekkoHttpBackend()
```

or, if you'd like to use an existing actor system:

```scala
import sttp.client3.pekkohttp._
import org.apache.pekko.actor.ActorSystem

val actorSystem: ActorSystem = ???
val backend = PekkoHttpBackend.usingActorSystem(actorSystem)
```

This backend supports sending and receiving [pekko-streams](https://pekko.apache.org/docs/pekko/current/stream/index.html) streams. The streams capability is represented as `sttp.client3.pekkohttp.PekkoStreams`.

To set the request body as a stream:

```scala
import sttp.capabilities.pekko.PekkoStreams
import sttp.client3._

import org.apache.pekko
import pekko.stream.scaladsl.Source
import pekko.util.ByteString

val source: Source[ByteString, Any] = ???

basicRequest
.post(uri"...")
.streamBody(PekkoStreams)(source)
```

To receive the response body as a stream:

```scala
import scala.concurrent.Future
import sttp.capabilities.pekko.PekkoStreams
import sttp.client3._
import sttp.client3.pekkohttp.PekkoHttpBackend

import org.apache.pekko
import pekko.stream.scaladsl.Source
import pekko.util.ByteString

val backend = PekkoHttpBackend()

val response: Future[Response[Either[String, Source[ByteString, Any]]]] =
basicRequest
.post(uri"...")
.response(asStreamUnsafe(PekkoStreams))
.send(backend)
```

The pekko-http backend support both regular and streaming [websockets](../websockets.md).

## Testing

Apart from testing using [the stub](../testing.md), you can create a backend using any `HttpRequest => Future[HttpResponse]` function, or an pekko-http `Route`.

That way, you can "mock" a server that the backend will talk to, without starting any actual server or making any HTTP calls.

If your application provides a client library for its dependants to use, this is a great way to ensure that the client actually matches the routes exposed by your application:

```scala
import sttp.client3.pekkohttp._
import org.apache.pekko
import pekko.http.scaladsl.server.Route
import pekko.actor.ActorSystem

val route: Route = ???
implicit val system: ActorSystem = ???

val backend = PekkoHttpBackend.usingClient(system, http = PekkoHttpClient.stubFromRoute(route))
```

## WebSockets

Non-standard behavior:

* pekko always automatically responds with a `Pong` to a `Ping` message
* `WebSocketFrame.Ping` and `WebSocketFrame.Pong` frames are ignored; instead, you can configure automatic [keep-alive pings](https://pekko.apache.org/docs/pekko-http/current/client-side/websocket-support.html#automatic-keep-alive-ping-support)

## Server-sent events

Received data streams can be parsed to a stream of server-sent events (SSE):

```scala
import scala.concurrent.Future

import org.apache.pekko.stream.scaladsl.Source

import sttp.capabilities.pekko.PekkoStreams
import sttp.client3.pekkohttp.PekkoHttpServerSentEvents
import sttp.model.sse.ServerSentEvent
import sttp.client3._

def processEvents(source: Source[ServerSentEvent, Any]): Future[Unit] = ???

basicRequest
.get(uri"...")
.response(asStream(PekkoStreams)(stream =>
processEvents(stream.via(PekkoHttpServerSentEvents.parse))))
```
2 changes: 1 addition & 1 deletion generated-docs/out/backends/scalaz.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The [Scalaz](https://github.com/scalaz/scalaz) backend is **asynchronous**. Send
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "armeria-backend-scalaz" % "3.8.16"
"com.softwaremill.sttp.client3" %% "armeria-backend-scalaz" % "3.9.0"
```

add imports:
Expand Down
6 changes: 3 additions & 3 deletions generated-docs/out/backends/synchronous.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ There are several synchronous backend implementations. Sending a request using t
The default **synchronous** backend. To use, you don't need any extra dependencies, `core` is enough:

```
"com.softwaremill.sttp.client3" %% "core" % "3.8.16"
"com.softwaremill.sttp.client3" %% "core" % "3.9.0"
```

Create the backend using:
Expand Down Expand Up @@ -40,7 +40,7 @@ Host header override is supported in environments running Java 12 onwards, but i
To use, you don't need any extra dependencies, `core` is enough:

```
"com.softwaremill.sttp.client3" %% "core" % "3.8.16"
"com.softwaremill.sttp.client3" %% "core" % "3.9.0"
```

Create the backend using:
Expand All @@ -62,7 +62,7 @@ This backend supports host header override, but it has to be enabled by system p
To use, add the following dependency to your project:

```
"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.8.16"
"com.softwaremill.sttp.client3" %% "okhttp-backend" % "3.9.0"
```

Create the backend using:
Expand Down
6 changes: 3 additions & 3 deletions generated-docs/out/backends/wrappers/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ object RateLimitingSttpBackend {
Implementing a new backend is made easy as the tests are published in the `core` jar file under the `tests` classifier. Simply add the follow dependencies to your `build.sbt`:

```
"com.softwaremill.sttp.client3" %% "core" % "3.8.16" % Test classifier "tests"
"com.softwaremill.sttp.client3" %% "core" % "3.9.0" % Test classifier "tests"
```

Implement your backend and extend the `HttpTest` class:
Expand Down Expand Up @@ -268,9 +268,9 @@ import sttp.client3.impl.cats.implicits._
from the cats integration module. The module should be available on the classpath after adding following dependency:

```scala
"com.softwaremill.sttp.client3" %% "cats" % "3.8.16" // for cats-effect 3.x
"com.softwaremill.sttp.client3" %% "cats" % "3.9.0" // for cats-effect 3.x
// or
"com.softwaremill.sttp.client3" %% "catsce2" % "3.8.16" // for cats-effect 2.x
"com.softwaremill.sttp.client3" %% "catsce2" % "3.9.0" // for cats-effect 2.x
```

The object contains implicits to convert a cats `MonadError` into the sttp `MonadError`,
Expand Down
Loading

0 comments on commit edc11d1

Please sign in to comment.