Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added jsonplaceholder link #2667

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/dsl/headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ More examples:
ZIO-HTTP provides a simple way to add headers to a client `Request`.

```scala mdoc:silent
val headers = Headers(Header.Host("sports.api.decathlon.com"), Header.Accept(MediaType.application.json))
Client.request(Request.get("http://sports.api.decathlon.com/test").addHeaders(headers))
val headers = Headers(Header.Host("jsonplaceholder.typicode.com"), Header.Accept(MediaType.application.json))
Client.request(Request.get("https://jsonplaceholder.typicode.com/todos").addHeaders(headers))
```

### Reading headers from `Response`

```scala mdoc:silent
Client.request(Request.get("http://sports.api.decathlon.com/test")).map(_.headers)
Client.request(Request.get("https://jsonplaceholder.typicode.com/todos")).map(_.headers)
```

<details>
Expand All @@ -132,9 +132,9 @@ import zio._
import zio.http._

object SimpleClientJson extends ZIOAppDefault {
val url = "http://sports.api.decathlon.com/groups/water-aerobics"
val url = "https://jsonplaceholder.typicode.com/todos"
// Construct headers
val headers = Headers(Header.Host("sports.api.decathlon.com"), Header.Accept(MediaType.application.json))
val headers = Headers(Header.Host("jsonplaceholder.typicode.com"), Header.Accept(MediaType.application.json))

val program = for {
// Pass headers to request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import zio.http._
import zio.http.netty.NettyConfig

object ClientWithDecompression extends ZIOAppDefault {
val url = URL.decode("http://sports.api.decathlon.com/groups/water-aerobics").toOption.get
val url = URL.decode("https://jsonplaceholder.typicode.com/todos").toOption.get

val program = for {
client <- ZIO.service[Client]
Expand Down
4 changes: 2 additions & 2 deletions zio-http-example/src/main/scala/example/HttpsClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import zio.http.netty.NettyConfig
import zio.http.netty.client.NettyClientDriver

object HttpsClient extends ZIOAppDefault {
val url = URL.decode("https://sports.api.decathlon.com/groups/water-aerobics").toOption.get
val headers = Headers(Header.Host("sports.api.decathlon.com"))
val url = URL.decode("https://jsonplaceholder.typicode.com/todos").toOption.get
val headers = Headers(Header.Host("jsonplaceholder.typicode.com"))

val sslConfig = ClientSSLConfig.FromTrustStoreResource(
trustStorePath = "truststore.jks",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zio._
import zio.http._

object SimpleClient extends ZIOAppDefault {
val url = URL.decode("http://sports.api.decathlon.com/groups/water-aerobics").toOption.get
val url = URL.decode("https://jsonplaceholder.typicode.com/todos").toOption.get

val program = for {
client <- ZIO.service[Client]
Expand Down
Loading