Struct webmachine_rust::context::WebmachineResponse
source · pub struct WebmachineResponse {
pub status: u16,
pub headers: BTreeMap<String, Vec<HeaderValue>>,
pub body: Option<Vec<u8>>,
}
Expand description
Response that is generated as a result of the webmachine execution
Fields§
§status: u16
status code to return
headers: BTreeMap<String, Vec<HeaderValue>>
headers to return
body: Option<Vec<u8>>
Response Body
Implementations§
source§impl WebmachineResponse
impl WebmachineResponse
sourcepub fn default() -> WebmachineResponse
pub fn default() -> WebmachineResponse
Creates a default response (200 OK)
sourcepub fn has_header(&self, header: &str) -> bool
pub fn has_header(&self, header: &str) -> bool
If the response has the provided header
sourcepub fn add_header(&mut self, header: &str, values: Vec<HeaderValue>)
pub fn add_header(&mut self, header: &str, values: Vec<HeaderValue>)
Adds the header values to the headers
sourcepub fn add_headers(&mut self, headers: HashMap<String, Vec<String>>)
pub fn add_headers(&mut self, headers: HashMap<String, Vec<String>>)
Adds the headers from a HashMap to the headers
sourcepub fn add_cors_headers(&mut self, allowed_methods: &Vec<&str>)
pub fn add_cors_headers(&mut self, allowed_methods: &Vec<&str>)
Adds standard CORS headers to the response
Trait Implementations§
source§impl Clone for WebmachineResponse
impl Clone for WebmachineResponse
source§fn clone(&self) -> WebmachineResponse
fn clone(&self) -> WebmachineResponse
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for WebmachineResponse
impl Debug for WebmachineResponse
source§impl PartialEq for WebmachineResponse
impl PartialEq for WebmachineResponse
source§fn eq(&self, other: &WebmachineResponse) -> bool
fn eq(&self, other: &WebmachineResponse) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for WebmachineResponse
Auto Trait Implementations§
impl Freeze for WebmachineResponse
impl RefUnwindSafe for WebmachineResponse
impl Send for WebmachineResponse
impl Sync for WebmachineResponse
impl Unpin for WebmachineResponse
impl UnwindSafe for WebmachineResponse
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more