pub struct ReplySpec {
pub payload: ReplyData,
pub status: Option<StatusCode>,
pub headers: HashMap<String, String>,
}Expand description
A builder for a reply with an explicit status and/or headers wrapped
around a payload. Start one with build_reply, chain the setters, and
finish with ReplySpec::done (which yields a ReplyData::Rich).
Fields§
§payload: ReplyDataThe body payload this spec decorates.
status: Option<StatusCode>The status code to send, or None to use the payload’s default.
headers: HashMap<String, String>Extra response headers, as name → value. Prefer ReplySpec::header
and ReplyData::add_header, which replace a header of the same name
in any letter case. Inserting here directly does not: two spellings of
one name would both reach the finalizer, and only one is sent.
Implementations§
Source§impl ReplySpec
impl ReplySpec
Sourcepub fn status(self, s: StatusCode) -> ReplySpec
pub fn status(self, s: StatusCode) -> ReplySpec
Set the response status code.
Sourcepub fn header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> ReplySpec
pub fn header( self, key: impl Into<String>, value: impl Into<String>, ) -> ReplySpec
Add a response header, replacing any already set whose name matches
case-insensitively (see ReplyData::add_header).
Sourcepub fn done(self) -> ReplyData
pub fn done(self) -> ReplyData
Finish the builder, producing a ReplyData::Rich.