pub struct LinoResult {
pub body: Body,
pub status: u16,
pub headers: Headers,
pub etag: bool,
pub preconditions: Option<bool>,
pub require_precondition: bool,
pub media_type: Option<String>,
}Expand description
A handler result carrying a status code and headers alongside the value.
Fields§
§body: BodyThe body.
status: u16HTTP status code.
headers: HeadersResponse headers.
etag: boolWhether to compute an entity tag for the representation.
preconditions: Option<bool>Whether to evaluate conditional request headers; None follows etag.
require_precondition: boolWhether an If-Match is required on unsafe methods.
media_type: Option<String>Media type to send, overriding the negotiated one.
Implementations§
Source§impl LinoResult
impl LinoResult
Sourcepub fn new(status: u16, body: Body) -> Self
pub fn new(status: u16, body: Body) -> Self
A result with a status and a body, and nothing else set.
Sourcepub fn with_header<N: Into<String>, V: Into<String>>(
self,
name: N,
value: V,
) -> Self
pub fn with_header<N: Into<String>, V: Into<String>>( self, name: N, value: V, ) -> Self
The same result with one more header.
§Examples
use lino_rest_api::response::ok;
use lino_rest_api::value::int;
let result = ok(int(1)).with_header("X-Trace", "abc");
assert_eq!(result.headers.get("x-trace"), Some("abc"));Sourcepub fn with_headers(self, headers: Headers) -> Self
pub fn with_headers(self, headers: Headers) -> Self
The same result with several more headers.
Sourcepub fn without_etag(self) -> Self
pub fn without_etag(self) -> Self
The same result without an entity tag, for bodies that are not worth caching or that change on every read.
Sourcepub fn with_preconditions(self, preconditions: bool) -> Self
pub fn with_preconditions(self, preconditions: bool) -> Self
The same result with conditional request evaluation turned on or off.
Sourcepub fn requiring_precondition(self, require: bool) -> Self
pub fn requiring_precondition(self, require: bool) -> Self
The same result demanding an If-Match on unsafe methods.
Sourcepub fn with_media_type<S: Into<String>>(self, media_type: S) -> Self
pub fn with_media_type<S: Into<String>>(self, media_type: S) -> Self
The same result sent as a concrete media type.
Trait Implementations§
Source§impl Clone for LinoResult
impl Clone for LinoResult
Source§fn clone(&self) -> LinoResult
fn clone(&self) -> LinoResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more