gleam-lang / gleam-lang/httpc

Sending `string_tree` / `bytes_tree` as body

Open
#58 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Gleam
Stars
175
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Hello!

As far as I understand, sending data over a socket as one would do with httpc is one of the cases where using an iolist (or Gleam `string_tree` / `bytes_tree`) would make sense, as the BEAM optimizes for that.

I don't think this currently possible with httpc, unless I'm missing something?

If I use gleam_json to construct a JSON payload to send as a body, the docs recommend serializing to a string tree https://hexdocs.pm/gleam_json/gleam/json.html#to_string_tree but if I wanted to send that body with httpc, I'd have to convert to string or bit_array to use `dispatch` or `dispatch_bits`.

Would a PR be accepted that adds `dispatch_string_tree` and `dispatch_bytes_tree` functions?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.