pub struct HttpResponse {
pub status_code: u16,
pub headers: HashMap<String, String>,
pub body: HttpBody,
}Expand description
HttpResponse is the response type that is available in handler. It is a more user-friendly version of RawHttpResponse After the handler is executed, it is converted to RawHttpResponse.
Fields§
§status_code: u16§headers: HashMap<String, String>§body: HttpBodyImplementations§
Source§impl HttpResponse
impl HttpResponse
Sourcepub fn add_raw_header(&mut self, key: &str, value: String)
pub fn add_raw_header(&mut self, key: &str, value: String)
Add a header to the response. If the header already exists, it will be overwritten.
Sourcepub fn remove_header(&mut self, key: &str)
pub fn remove_header(&mut self, key: &str)
Remove a header from the response. If the header does not exist, nothing will happen.
Trait Implementations§
Source§impl Clone for HttpResponse
impl Clone for HttpResponse
Source§fn clone(&self) -> HttpResponse
fn clone(&self) -> HttpResponse
Returns a duplicate 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 HttpResponse
impl Debug for HttpResponse
Source§impl From<HttpResponse> for RawHttpResponse
impl From<HttpResponse> for RawHttpResponse
Source§fn from(res: HttpResponse) -> Self
fn from(res: HttpResponse) -> Self
Converts to this type from the input type.
Source§impl PartialEq for HttpResponse
impl PartialEq for HttpResponse
impl StructuralPartialEq for HttpResponse
Auto Trait Implementations§
impl Freeze for HttpResponse
impl RefUnwindSafe for HttpResponse
impl Send for HttpResponse
impl Sync for HttpResponse
impl Unpin for HttpResponse
impl UnwindSafe for HttpResponse
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