wip: currently rewriting the project as a full stack application tangled.org/kacaii.dev/sigo
gleam
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

:art: use pipes

Kacaii 9ec50a0b 970a6460

+13 -10
+13 -10
src/app/web/socket.gleam
··· 11 11 import gleam/erlang/process 12 12 import gleam/http/request 13 13 import gleam/http/response 14 + import gleam/int 14 15 import gleam/json 15 16 import gleam/list 16 17 import gleam/option ··· 274 275 275 276 decode.success(subscribe_to) 276 277 }) 278 + 277 279 parse_result 278 280 } 279 281 280 - fn read_body(req: request.Request(mist.Connection)) -> Result(String, Nil) { 281 - use req <- try( 282 - mist.read_body(req, 1024 * 1024 * 10) 283 - |> result.replace_error(Nil), 284 - ) 282 + fn read_body( 283 + req: request.Request(mist.Connection), 284 + ) -> Result(String, mist.ReadError) { 285 + let max_body_limit = 286 + request.get_header(req, "content-length") 287 + |> result.try(int.parse) 288 + |> result.unwrap(0) 285 289 286 - use body <- result.map( 287 - bit_array.to_string(req.body) 288 - |> result.replace_error(Nil), 289 - ) 290 + use req <- result.map(mist.read_body(req, max_body_limit:)) 290 291 291 - body 292 + req.body 293 + |> bit_array.to_string 294 + |> result.unwrap("") 292 295 } 293 296 294 297 // ON CLOSE --------------------------------------------------------------------