Open Geal opened 1 year ago
Rhai has a first class type for representing bytes: https://rhai.rs/book/ref/blobs.html
We could leverage this to think about a progressive representation such that:
First
We could provide a basic interface which provides a rhai callback function a Blob
each time it is received in the router.
At this time, anyone wanting to manipulate this data from a Rhai script would be restricted to the features provided by the Blob.
Second
We could provide some utility functions which provide some common functionality for manipulating Blobs. e.g.: try to convert to JSON, try to convert to multipart, etc...
Some questions/observations:
It feels like this might be a good approach for at least starting to explore the problem.
in https://github.com/apollographql/router/pull/3234 we provided a way to access Router service level requests and responses. At this step, the body is a stream of byte chunks, with no real guarantee about the format:
Due to these issues, we do not give access to the body, until we can provide a good API to manipulate it