reactr
reactr copied to clipboard
Undocumented Request API methods
I noticed a couple inconsistencies between Runnable API and documentationthat I wanted to document below to allow for tracking and further discussions.
- There is a variety of
set*
methods in some languages (e.g. Rust) which are there to enable experimentation with runnables implementing some middleware-functionality. These are intentionally undocumented for now as the API ergonomy and usecases are developed. - In JavaScript the
body
method returns a JSstring
. and thebodyBytes
method needs to be used to get the raw bytes. Other runtime seem to default tobody
returning the raw bytes. - The
state
method in every supported language seem to return the state key value as a string, JavaScript and some other languages also provide a "raw" method (state_raw
orstateBytes
) to get the raw bytes which is undocumented.
@ospencer could you have a look at 2./3. here and comment on whether they are intended or improving the consistency here would be useful / planned?
Particularly if 3.) is correct and raw bytes for state keys are useful, we should ensure this is also supported by all languages, not only JS/TS.
In JS, the result of an HTTP request is a custom HttpResponse
class, with methods text()
to get the body as a string, json()
for JSON, and arrayBuffer()
for an ArrayBuffer. It was done this way to feel the most idiomatic for JS... Consistency across languages is tough. Ideally, the API provided by Reactr's interface would be "good enough" for each language. I have lots of thoughts about this that we should probably schedule some time to chat through.
As for state, I don't think that access to the raw bytes is particularly useful, and we should maybe remove it and standardize across the languages.