This commit is contained in:
		
							parent
							
								
									86841f6190
								
							
						
					
					
						commit
						02ee76a2ed
					
				
					 1 changed files with 12 additions and 0 deletions
				
			
		|  | @ -4,6 +4,7 @@ import gleam/erlang/process | |||
| import gleam/http | ||||
| import gleam/http/request.{type Request} | ||||
| import gleam/http/response.{type Response} | ||||
| import gleam/int | ||||
| import gleam/io | ||||
| import gleam/iterator | ||||
| 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())) | ||||
|   }) | ||||
| } | ||||
| 
 | ||||
| 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") | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue