Skip to content

Commit

Permalink
Native example
Browse files Browse the repository at this point in the history
  • Loading branch information
adamw committed Jan 8, 2025
1 parent cb737df commit 18a0c90
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/backends/javascript/fetch.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# JavaScript (Fetch) backend
# Scala.js (Fetch) backend

A JavaScript backend with web socket support. Implemented using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).

Expand Down
25 changes: 23 additions & 2 deletions docs/backends/native/curl.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Curl backend
# Scala Native (curl) backend

A Scala Native backend implemented using [Curl](https://github.com/curl/curl/blob/master/include/curl/curl.h).
A Scala Native (0.5.x) backend implemented using [Curl](https://github.com/curl/curl/blob/master/include/curl/curl.h).

To use, add the following dependency to your project:

Expand All @@ -11,9 +11,30 @@ To use, add the following dependency to your project:
and initialize one of the backends:

```scala
import sttp.client4.curl.*

val backend = CurlBackend()
val tryBackend = CurlTryBackend()
```

You need to have an environment with Scala Native [setup](https://scala-native.readthedocs.io/en/latest/user/setup.html)
with additionally installed `libcrypto` (included in OpenSSL) and `curl` in version `7.56.0` or newer.

## scala-cli example

Try the following example:

```scala
// hello.scala

//> using platform native
//> using dep com.softwaremill.sttp.client4::core_native0.5:@VERSION@

import sttp.client4.*
import sttp.client4.curl.CurlBackend

@main def run(): Unit =
val backend = CurlBackend()
println(basicRequest.get(uri"http://httpbin.org/ip").send(backend))
```

0 comments on commit 18a0c90

Please sign in to comment.