Struct salvo_core::http::response::Response
source · pub struct Response { /* private fields */ }
Expand description
Represents an HTTP response
Implementations§
source§impl Response
impl Response
Creates a new blank Response
.
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get mutable headers reference.
sourcepub fn set_headers(&mut self, headers: HeaderMap)
pub fn set_headers(&mut self, headers: HeaderMap)
Sets headers.
sourcepub fn add_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<()>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
pub fn add_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<()>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
Modify a header for this response.
When overwrite
is set to true
, If the header is already present, the value will be replaced.
When overwrite
is set to false
, The new header is always appended to the request, even if the header already exists.
sourcepub fn with_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<&mut Self>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
pub fn with_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<&mut Self>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
Modify a header for this response.
When overwrite
is set to true
, If the header is already present, the value will be replaced.
When overwrite
is set to false
, The new header is always appended to the request, even if the header already exists.
sourcepub fn version_mut(&mut self) -> &mut Version
pub fn version_mut(&mut self) -> &mut Version
Get mutable version reference.
sourcepub fn replace_body(&mut self, body: ResBody) -> ResBody
pub fn replace_body(&mut self, body: ResBody) -> ResBody
Sets body to a new value and returns old value.
Available on crate feature cookie
only.
cookie
only.Get cookies reference.
Available on crate feature cookie
only.
cookie
only.Get mutable cookies reference.
Available on crate feature cookie
only.
cookie
only.Helper function for get cookie.
Available on crate feature cookie
only.
cookie
only.Helper function for add cookie.
Available on crate feature cookie
only.
cookie
only.Helper function for add cookie.
Available on crate feature cookie
only.
cookie
only.Helper function for remove cookie.
Removes cookie
from this CookieJar. If an original cookie with the same
name as cookie
is present in the jar, a removal cookie will be
present in the delta
computation.
A “removal” cookie is a cookie that has the same name as the original cookie but has an empty value, a max-age of 0, and an expiration date far in the past. Read more about removal cookies.
sourcepub fn status_code(&self) -> Option<StatusCode>
pub fn status_code(&self) -> Option<StatusCode>
Get status code.
sourcepub fn set_status_code(&mut self, code: StatusCode)
pub fn set_status_code(&mut self, code: StatusCode)
Sets status code.
sourcepub fn with_status_code(&mut self, code: StatusCode) -> &mut Self
pub fn with_status_code(&mut self, code: StatusCode) -> &mut Self
Sets status code.
sourcepub fn content_type(&self) -> Option<Mime>
pub fn content_type(&self) -> Option<Mime>
Get content type.
sourcepub fn status_error(&self) -> Option<&StatusError>
pub fn status_error(&self) -> Option<&StatusError>
Get http error if exists, only exists after use set_status_error
set http error.
sourcepub fn set_status_error(&mut self, err: StatusError)
pub fn set_status_error(&mut self, err: StatusError)
Sets http error.
sourcepub fn with_status_error(&mut self, err: StatusError) -> &mut Self
pub fn with_status_error(&mut self, err: StatusError) -> &mut Self
Sets http error.
sourcepub fn with_render<P>(&mut self, piece: P) -> &mut Selfwhere
P: Piece,
pub fn with_render<P>(&mut self, piece: P) -> &mut Selfwhere
P: Piece,
Render content.
sourcepub fn stuff<P>(&mut self, code: StatusCode, piece: P)where
P: Piece,
pub fn stuff<P>(&mut self, code: StatusCode, piece: P)where
P: Piece,
Render content with status code.
sourcepub fn with_stuff<P>(&mut self, code: StatusCode, piece: P) -> &mut Selfwhere
P: Piece,
pub fn with_stuff<P>(&mut self, code: StatusCode, piece: P) -> &mut Selfwhere
P: Piece,
Render content with status code.
Trait Implementations§
source§impl ResponseExt for Response
Available on crate feature test
only.
impl ResponseExt for Response
test
only.source§fn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
String
from response.source§fn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
Self: 'async_trait,
'life0: 'async_trait,
fn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
Self: 'async_trait,
'life0: 'async_trait,
T
instance.source§fn take_string_with_charset<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
charset: &'life1 str,
compress: Option<&'life2 str>
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn take_string_with_charset<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
charset: &'life1 str,
compress: Option<&'life2 str>
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
String
from response with charset.