Add chunk funciton
Some checks are pending
test / test (push) Waiting to run

This commit is contained in:
Em (Ethan) Ruszanowski 2024-07-23 17:09:53 -04:00
parent 86841f6190
commit 02ee76a2ed
Signed by: em
GPG key ID: C725D6E571252B96

View file

@ -4,6 +4,7 @@ import gleam/erlang/process
import gleam/http import gleam/http
import gleam/http/request.{type Request} import gleam/http/request.{type Request}
import gleam/http/response.{type Response} import gleam/http/response.{type Response}
import gleam/int
import gleam/io import gleam/io
import gleam/iterator import gleam/iterator
import gleam/option.{None, Some} import gleam/option.{None, Some}
@ -84,3 +85,14 @@ fn echo_body(request: Request(Connection)) -> Response(ResponseData) {
|> response.set_body(mist.Bytes(bytes_builder.new())) |> response.set_body(mist.Bytes(bytes_builder.new()))
}) })
} }
fn serve_chunk(_request: Request(Connection)) -> Response(ResponseData) {
let iter =
["one", "two", "three"]
|> iterator.from_list
|> iterator.map(bytes_builder.from_string)
response.new(200)
|> response.set_body(mist.Chunked(iter))
|> response.set_header("content-type", "text/plain")
}