Skip to content

Commit fc03f2a

Browse files
committed
Migrate examples & docs to Scala 3
1 parent 462eeaf commit fc03f2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+472
-563
lines changed

build.sbt

Lines changed: 76 additions & 91 deletions
Large diffs are not rendered by default.

docs/backends/akka.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Note that you'll also need an explicit dependency on akka-streams, as akka-http
1616

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

19-
```scala mdoc:compile-only
19+
```scala
2020
import sttp.client4.akkahttp._
2121
val backend = AkkaHttpBackend()
2222
```
2323

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

26-
```scala mdoc:compile-only
26+
```scala
2727
import sttp.client4.akkahttp._
2828
import akka.actor.ActorSystem
2929

@@ -35,7 +35,7 @@ This backend supports sending and receiving [akka-streams](http://doc.akka.io/do
3535

3636
To set the request body as a stream:
3737

38-
```scala mdoc:compile-only
38+
```scala
3939
import sttp.capabilities.akka.AkkaStreams
4040
import sttp.client4._
4141

@@ -51,7 +51,7 @@ basicRequest
5151

5252
To receive the response body as a stream:
5353

54-
```scala mdoc:compile-only
54+
```scala
5555
import scala.concurrent.Future
5656
import sttp.capabilities.akka.AkkaStreams
5757
import sttp.client4._
@@ -79,7 +79,7 @@ That way, you can "mock" a server that the backend will talk to, without startin
7979

8080
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:
8181

82-
```scala mdoc:compile-only
82+
```scala
8383
import sttp.client4.akkahttp._
8484
import akka.http.scaladsl.server.Route
8585
import akka.actor.ActorSystem
@@ -101,7 +101,7 @@ Non-standard behavior:
101101

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

104-
```scala mdoc:compile-only
104+
```scala
105105
import scala.concurrent.Future
106106

107107
import akka.stream.scaladsl.Source

docs/backends/fs2.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ or, if you'd like to instantiate the [WebClient](https://armeria.dev/docs/client
102102
import cats.effect.IO
103103
import cats.effect.std.Dispatcher
104104
import com.linecorp.armeria.client.WebClient
105-
import com.linecorp.armeria.client.circuitbreaker._
105+
import com.linecorp.armeria.client.circuitbreaker.*
106106
import sttp.client4.armeria.fs2.ArmeriaFs2Backend
107107

108108
val dispatcher: Dispatcher[IO] = ???
@@ -135,7 +135,7 @@ Requests can be sent with a streaming body like this:
135135
import cats.effect.IO
136136
import fs2.Stream
137137
import sttp.capabilities.fs2.Fs2Streams
138-
import sttp.client4._
138+
import sttp.client4.*
139139
import sttp.client4.httpclient.fs2.HttpClientFs2Backend
140140

141141
val effect = HttpClientFs2Backend.resource[IO]().use { backend =>
@@ -155,7 +155,7 @@ Responses can also be streamed:
155155
import cats.effect.IO
156156
import fs2.Stream
157157
import sttp.capabilities.fs2.Fs2Streams
158-
import sttp.client4._
158+
import sttp.client4.*
159159
import sttp.client4.httpclient.fs2.HttpClientFs2Backend
160160
import scala.concurrent.duration.Duration
161161

@@ -181,9 +181,9 @@ The fs2 backends support both regular and streaming [websockets](../websockets.m
181181
Received data streams can be parsed to a stream of server-sent events (SSE):
182182

183183
```scala mdoc:compile-only
184-
import cats.effect._
184+
import cats.effect.*
185185
import fs2.Stream
186-
import sttp.client4._
186+
import sttp.client4.*
187187
import sttp.capabilities.fs2.Fs2Streams
188188
import sttp.client4.impl.fs2.Fs2ServerSentEvents
189189
import sttp.model.sse.ServerSentEvent

docs/backends/future.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
There are several backend implementations which are `scala.concurrent.Future`-based. These backends are **asynchronous**, sending a request is a non-blocking operation and results in a response wrapped in a `Future`.
44

5-
Apart from the ones described below, also the [Akka](akka.md) backend is `Future`-based.
5+
Apart from the ones described below, also the [Pekko](pekko.md) & [Akka](akka.md) backends are `Future`-based.
66

77
```eval_rst
8-
===================================== ================================================ ==========================
9-
Class Supported stream type Websocket support
10-
===================================== ================================================ ==========================
11-
``HttpClientFutureBackend`` n/a yes (regular)
12-
``AkkaHttpBackend`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming)
13-
``OkHttpFutureBackend`` n/a yes (regular)
14-
``ArmeriaFutureBackend`` n/a n/a
15-
===================================== ================================================ ==========================
8+
===================================== ================================================= ==========================
9+
Class Supported stream type Websocket support
10+
===================================== ================================================= ==========================
11+
``HttpClientFutureBackend`` n/a yes (regular)
12+
``PekkoHttpBackend`` ``pekko.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming)
13+
``AkkaHttpBackend`` ``akka.stream.scaladsl.Source[ByteString, Any]`` yes (regular & streaming)
14+
``OkHttpFutureBackend`` n/a yes (regular)
15+
``ArmeriaFutureBackend`` n/a n/a
16+
===================================== ================================================= ==========================
1617
```
1718

1819
## Using HttpClient
@@ -111,7 +112,7 @@ ArmeriaFutureBackend.usingDefaultClient()
111112
or, if you'd like to instantiate the [WebClient](https://armeria.dev/docs/client-http) yourself::
112113

113114
```scala mdoc:compile-only
114-
import com.linecorp.armeria.client.circuitbreaker._
115+
import com.linecorp.armeria.client.circuitbreaker.*
115116
import com.linecorp.armeria.client.WebClient
116117

117118
// Fluently build Armeria WebClient with built-in decorators

docs/backends/http4s.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ This backend is based on [http4s](https://http4s.org) (client) and is **asynchro
1111
The backend can be created in a couple of ways, e.g.:
1212

1313
```scala mdoc:compile-only
14-
import cats.effect._
14+
import cats.effect.*
1515
import sttp.capabilities.fs2.Fs2Streams
16-
import sttp.client4._
17-
import sttp.client4.http4s._
16+
import sttp.client4.*
17+
import sttp.client4.http4s.*
1818

1919
// the "org.http4s" %% "http4s-ember-client" % http4sVersion dependency needs to be explicitly added
2020
Http4sBackend.usingDefaultEmberClientBuilder[IO](): Resource[IO, StreamBackend[IO, Fs2Streams[IO]]]

docs/backends/javascript/fetch.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ To use, add the following dependency to your project:
135135
An example of streaming a response:
136136

137137
```scala
138-
import sttp.client4._
139-
import sttp.client4.impl.monix._
138+
import sttp.client4.*
139+
import sttp.client4.impl.monix.*
140140

141141
import java.nio.ByteBuffer
142142
import monix.eval.Task
@@ -170,7 +170,7 @@ import monix.eval.Task
170170
import sttp.capabilities.monix.MonixStreams
171171
import sttp.client4.impl.monix.MonixServerSentEvents
172172
import sttp.model.sse.ServerSentEvent
173-
import sttp.client4._
173+
import sttp.client4.*
174174

175175
def processEvents(source: Observable[ServerSentEvent]): Task[Unit] = ???
176176

docs/backends/monix.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ArmeriaMonixBackend.usingDefaultClient()
9797
or, if you'd like to instantiate the [WebClient](https://armeria.dev/docs/client-http) yourself:
9898

9999
```scala
100-
import com.linecorp.armeria.client.circuitbreaker._
100+
import com.linecorp.armeria.client.circuitbreaker.*
101101
import com.linecorp.armeria.client.WebClient
102102

103103
// Fluently build Armeria WebClient with built-in decorators
@@ -124,7 +124,7 @@ The Monix backends support streaming. The streams capability is represented as `
124124

125125
```scala
126126
import sttp.capabilities.monix.MonixStreams
127-
import sttp.client4._
127+
import sttp.client4.*
128128
import sttp.client4.httpclient.monix.HttpClientMonixBackend
129129

130130
import monix.reactive.Observable
@@ -143,7 +143,7 @@ And receive responses as an observable stream:
143143

144144
```scala
145145
import sttp.capabilities.monix.MonixStreams
146-
import sttp.client4._
146+
import sttp.client4.*
147147
import sttp.client4.httpclient.monix.HttpClientMonixBackend
148148

149149
import monix.eval.Task
@@ -176,7 +176,7 @@ import monix.eval.Task
176176
import sttp.capabilities.monix.MonixStreams
177177
import sttp.client4.impl.monix.MonixServerSentEvents
178178
import sttp.model.sse.ServerSentEvent
179-
import sttp.client4._
179+
import sttp.client4.*
180180

181181
def processEvents(source: Observable[ServerSentEvent]): Task[Unit] = ???
182182

docs/backends/pekko.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ Note that you'll also need an explicit dependency on pekko-streams, as pekko-htt
1717
Next you'll need to add create the backend instance:
1818

1919
```scala mdoc:compile-only
20-
import sttp.client4.pekkohttp._
20+
import sttp.client4.pekkohttp.*
2121
val backend = PekkoHttpBackend()
2222
```
2323

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

2626
```scala mdoc:compile-only
27-
import sttp.client4.pekkohttp._
27+
import sttp.client4.pekkohttp.*
2828
import org.apache.pekko.actor.ActorSystem
2929

3030
val actorSystem: ActorSystem = ???
@@ -37,7 +37,7 @@ To set the request body as a stream:
3737

3838
```scala mdoc:compile-only
3939
import sttp.capabilities.pekko.PekkoStreams
40-
import sttp.client4._
40+
import sttp.client4.*
4141

4242
import org.apache.pekko
4343
import pekko.stream.scaladsl.Source
@@ -55,7 +55,7 @@ To receive the response body as a stream:
5555
```scala mdoc:compile-only
5656
import scala.concurrent.Future
5757
import sttp.capabilities.pekko.PekkoStreams
58-
import sttp.client4._
58+
import sttp.client4.*
5959
import sttp.client4.pekkohttp.PekkoHttpBackend
6060

6161
import org.apache.pekko
@@ -82,7 +82,7 @@ That way, you can "mock" a server that the backend will talk to, without startin
8282
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:
8383

8484
```scala mdoc:compile-only
85-
import sttp.client4.pekkohttp._
85+
import sttp.client4.pekkohttp.*
8686
import org.apache.pekko
8787
import pekko.http.scaladsl.server.Route
8888
import pekko.actor.ActorSystem

docs/backends/scalaz.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ To use, add the following dependency to your project:
1313

1414
add imports:
1515

16-
```scala mdoc:silent
16+
```scala
1717
import sttp.client4.armeria.scalaz.ArmeriaScalazBackend
1818
```
1919

2020
create client:
2121

22-
```scala mdoc:compile-only
22+
```scala
2323
val backend = ArmeriaScalazBackend()
2424

2525
// You can use the default client which reuses the connection pool of ClientFactory.ofDefault()
@@ -28,7 +28,7 @@ ArmeriaScalazBackend.usingDefaultClient()
2828

2929
or, if you'd like to instantiate the [WebClient](https://armeria.dev/docs/client-http) yourself:
3030

31-
```scala mdoc:compile-only
31+
```scala
3232
import com.linecorp.armeria.client.circuitbreaker._
3333
import com.linecorp.armeria.client.WebClient
3434

docs/backends/synchronous.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ or, if you'd like to instantiate the OkHttpClient yourself:
7777

7878
```scala mdoc:compile-only
7979
import sttp.client4.okhttp.OkHttpSyncBackend
80-
import okhttp3._
80+
import okhttp3.*
8181

8282
val okHttpClient: OkHttpClient = ???
8383
val backend = OkHttpSyncBackend.usingClient(okHttpClient)

0 commit comments

Comments
 (0)