Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow consumers to respond with freeform bodies and a particular status code #310

Merged
merged 6 commits into from
Apr 9, 2022

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 jessfraz and davepacheco 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!

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.

2 participants