Skip to content

Commit

Permalink
Fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo committed Dec 22, 2023
1 parent 48b74b5 commit c3b3afc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/dsl/body.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ To create an `Body` that encodes a Stream you can use `Body.fromStream`.
- Using a Stream of Bytes

```scala mdoc:silent
val streamHttpData1: Body = Body.fromStream(ZStream.fromChunk(Chunk.fromArray("Some String".getBytes(Charsets.Http))))
val streamHttpData1: Body = Body.fromStreamChunked(ZStream.fromChunk(Chunk.fromArray("Some String".getBytes(Charsets.Http))))
```

- Using a Stream of String

```scala mdoc:silent
val streamHttpData2: Body = Body.fromCharSequenceStream(ZStream("a", "b", "c"), Charsets.Http)
val streamHttpData2: Body = Body.fromCharSequenceStreamChunked(ZStream("a", "b", "c"), Charsets.Http)
```

### Creating a Body from a `File`

To create an `Body` that encodes a File you can use `Body.fromFile`:

```scala mdoc:silent:crash
val fileHttpData: Body = Body.fromFile(new java.io.File(getClass.getResource("/fileName.txt").getPath))
val fileHttpData: ZIO[Any, Nothing, Body] = Body.fromFile(new java.io.File(getClass.getResource("/fileName.txt").getPath))
```
4 changes: 1 addition & 3 deletions docs/dsl/headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ object SimpleResponseDispatcher extends ZIOAppDefault {
if (acceptsStreaming)
Response(
status = Status.Ok,
// Setting response header
headers = Headers(Header.ContentLength(message.length.toLong)), // adding CONTENT-LENGTH header
body = Body.fromStream(ZStream.fromChunk(message)), // Encoding content using a ZStream
body = Body.fromStream(ZStream.fromChunk(message), message.length.toLong), // Encoding content using a ZStream
)
else {
// Adding a custom header to Response
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/advanced/streaming-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object FileStreaming extends ZIOAppDefault {

// Read the file as ZStream
// Uses the blocking version of ZStream.fromFile
Method.GET / "blocking" -> Handler.fromStream(ZStream.fromPath(Paths.get("README.md"))),
Method.GET / "blocking" -> Handler.fromStreamChunked(ZStream.fromPath(Paths.get("README.md"))),

// Uses netty's capability to write file content to the Channel
// Content-type response headers are automatically identified and added
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/advanced/streaming-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ object StreamingResponse extends ZIOAppDefault {
handler(
http.Response(
status = Status.Ok,
headers = Headers(Header.ContentLength(message.length.toLong)),
body = Body.fromStream(ZStream.fromChunk(message)), // Encoding content using a ZStream
body = Body.fromStream(ZStream.fromChunk(message), message.length.toLong), // Encoding content using a ZStream
),
),
).toHttpApp
Expand Down

0 comments on commit c3b3afc

Please sign in to comment.