edgedb
edgedb copied to clipboard
Simplify scheduling HTTP JSON request
Based on a discussion regarding an upcoming blog post and common needs when using net::http, there is a clear use case for simpler handling of JSON data when making HTTP requests.
We should consider adding:
- A built-in function, e.g.,
to_bytes(<json>), to easily convert JSON values to bytes. This would be useful for preparing JSON bodies for HTTP requests or other byte-oriented operations. - An overload or sugar function for net::http::request (e.g.,
net::http::schedule_json_request) that simplifies sending JSON bodies. This function could automatically handle setting theContent-Type: application/jsonheader and converting the provided JSON value to bytes using the new to_bytes function internally.
This would reduce boilerplate for users making JSON-based API calls using the net::http module.