You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the "response emitter" has a single Emit function that magically determines the right thing to do. Unfortunately, this is really magical:
We have a special "single" wrapper to inform HTTP that we're emitting a single value.
If the user "emits" a reader, we copy it as a stream of bytes.
If the user emits normal values (not Single, we emit a stream of values).
This is getting better with the next iteration of the commands lib (this list used to include errors) but it could be improved.
Solutions:
Have different command types. While the nicest from a type safety standpoint, this may not be the friendliest option.
Apply a type-switch to the command's Run (and PostRun) functions. Personally, this is the one I'd vote for.
In the second case, we'd allow the following Run signatures:
// Writes a streamtypeStreamFuncfunc(req*Request, resp io.Writer, envEnvironment) error// Streams items//// We can keep this "magical" for now but eventually remove the magic and force users to use the other variants.typeEmitterFuncfunc(req*Request, respResponseEmitter, envEnvironment) error// Sends a single itemtypeSingleFuncfunc(req*Request, envEnvironment) (interface{}, error)
Thoughts? This should make sending HTTP responses simpler and will likely improve user experience.
The text was updated successfully, but these errors were encountered:
Currently, the "response emitter" has a single
Emit
function that magically determines the right thing to do. Unfortunately, this is really magical:Single
, we emit a stream of values).This is getting better with the next iteration of the commands lib (this list used to include errors) but it could be improved.
Solutions:
In the second case, we'd allow the following
Run
signatures:Thoughts? This should make sending HTTP responses simpler and will likely improve user experience.
The text was updated successfully, but these errors were encountered: