Repository navigation
Tidyup and prepare for 0.14 - #2
Merged
Merged
Conversation
…ped request param
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IntoBodytrait. Unwrap body types directly instead, either by pattern matching in the handler arguments (eg|Capped(FromJson(body)): Capped<FromJson<T>, N>| ...) or via.0.Option<T>is now described asOneOf [T, Null](ieT | null) rather thanOptional, since serde serializesNoneasnull. Previously, clients generated from the info would wrongly expect the key to be omitted.#[api_body(optional)]forOption<T>fields inApiBodystructs and enum variants. The field is described asOptional(ie{ key?: T }), is omitted from the JSON whenNone, and is treated asNonewhen missing.#[api_body(flatten)]on an enum variant field is now a clear compile error rather than a confusing one.HandlerBody::handler_method()no longer defaults to POST and must be implemented by everyHandlerBodytype. Custom body types that relied on the default should addfn handler_method() -> Method { Method::POST }.Capped<T, N>always reporting POST as its handler method; it now usesT's method, so wrapping a body type that expects eg PUT no longer changes the route.Api::handle()andHandlerResponse::handler_response()now produce anhttp::Response<seamless::handler::response::Body>rather than anhttp::Response<Vec<u8>>. ABodyis either a complete set of bytes (useBody::as_bytes()orBody::into_bytes()to get at them without streaming) or a stream ofbytes::Byteschunks (useBody::into_stream()to obtain aBodyStream, which implementsfutures::Stream). Code which previously usedres.into_body()as aVec<u8>can useres.into_body().into_vec()instead, though it's better to pass streaming bodies on to your HTTP framework as streams (see the Axum and Hyper examples).ToBinaryresponse type, which responds with arbitrary bytes, optionally streamed from afutures::Streamorfutures::AsyncRead, and which allows thecontent-typeandcontent-lengthheaders to be set. Thecontent-lengthis set automatically when the body is already in memory.ToJsonno longer panics if the value fails to serialize (eg a map with non-string keys, or a customSerializeimpl that errors). A 500ApiErroris returned instead, with the serialization error in itsinternal_message.