-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upgrade to zio 2.0.0-RC1 * bump timeout for failing test * other fixes * increase timeout * rejigger broken test * try, try again * get compiling & tests passing Co-authored-by: Kit Langton <kit.langton@gmail.com>
- Loading branch information
1 parent
4b760b4
commit 7660b9c
Showing
77 changed files
with
458 additions
and
420 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# CORS Handling | ||
|
||
```scala | ||
import zhttp.http._ | ||
import zhttp.service.Server | ||
import zio._ | ||
|
||
object HelloWorldWithCORS extends ZIOAppDefault { | ||
// Create HTTP route with CORS enabled | ||
val app: HttpApp[Any, Nothing] = CORS( | ||
Http.collect[Request] { | ||
case Method.GET -> !! / "text" => Response.text("Hello World!") | ||
case Method.GET -> !! / "json" => Response.jsonString("""{"greetings": "Hello World!"}""") | ||
}, | ||
config = CORSConfig(anyOrigin = true), | ||
) | ||
|
||
// Run it like any simple app | ||
val run = | ||
Server.start(8090, app.silent) | ||
} | ||
``` |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 13 additions & 8 deletions
21
docs/website/docs/v1.x/examples/zio-http-basic-examples/simple-client.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
# Simple HTTP Client | ||
```scala | ||
import zhttp.http.Headers | ||
import zhttp.http.{Header, HttpData} | ||
import zhttp.service.{ChannelFactory, Client, EventLoopGroup} | ||
import zio._ | ||
|
||
object SimpleClient extends App { | ||
object SimpleClient extends ZIOAppDefault { | ||
val env = ChannelFactory.auto ++ EventLoopGroup.auto() | ||
val url = "http://sports.api.decathlon.com/groups/water-aerobics" | ||
val headers = Headers.host("sports.api.decathlon.com") | ||
val headers = List(Header.host("sports.api.decathlon.com")) | ||
|
||
val program = for { | ||
res <- Client.request(url, headers) | ||
data <- res.getBodyAsString | ||
_ <- console.putStrLn { data } | ||
res <- Client.request(url, headers) | ||
_ <- console.putStrLn { | ||
res.content match { | ||
case HttpData.CompleteData(data) => data.map(_.toChar).mkString | ||
case HttpData.StreamData(_) => "<Chunked>" | ||
case HttpData.Empty => "" | ||
} | ||
} | ||
} yield () | ||
|
||
override def run(args: List[String]): URIO[zio.ZEnv, ExitCode] = | ||
program.exitCode.provideCustomLayer(env) | ||
override val run = | ||
program.provide(env) | ||
|
||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.