Skip to content

Conversation

@ahl
Copy link
Collaborator

@ahl ahl commented Mar 28, 2022

For crucible and the update system, it's useful to be able to respond with a freeform body. Dropshot allows this today, but doing so removes both the expected status code and structural information about errors. This introduces a endpoint response type:

async fn stream_bytes_at_me_please(
    rqctx: Arc<RequestContext<()>>,
) -> Result<HttpResponseOk<FreeformBody>, HttpError> {
    let (sender, body) = Body::channel();
    // spawn a task to spew bytes into `sender`
    Ok(HttpResponseOk(body.into()))
}

Note this involves some reshuffling of types--I think--for the better. For example, Empty no longer impls Serialize or JsonSchema and the numeric response code trait is separated from the content trait.

@ahl ahl changed the title WIP: allow consumers to respond with free form bodies and a particular status code allow consumers to respond with free form bodies and a particular status code Apr 7, 2022
@ahl ahl changed the title allow consumers to respond with free form bodies and a particular status code allow consumers to respond with freeform bodies and a particular status code Apr 7, 2022
@ahl ahl requested review from davepacheco and jessfraz April 7, 2022 19:08
@ahl ahl marked this pull request as ready for review April 7, 2022 19:08
@jessfraz
Copy link
Contributor

jessfraz commented Apr 7, 2022

oh cool!

@ahl ahl merged commit c959910 into main Apr 9, 2022
@ahl ahl deleted the body branch April 9, 2022 00:47
davepacheco added a commit that referenced this pull request Apr 15, 2022
davepacheco added a commit that referenced this pull request Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants