pub struct HttpResponseBuilder { /* private fields */ }Expand description
Builder struct for constructing an HTTP response.
Implementations§
Source§impl HttpResponseBuilder
impl HttpResponseBuilder
Sourcepub fn new(status: HttpStatus) -> Self
pub fn new(status: HttpStatus) -> Self
Create a builder with a custom status.
Sourcepub fn no_content() -> Self
pub fn no_content() -> Self
Shortcut for 204 No Content.
Sourcepub fn bad_request() -> Self
pub fn bad_request() -> Self
Shortcut for 400 Bad Request.
Shortcut for 401 Unauthorized.
Sourcepub fn internal_server_error() -> Self
pub fn internal_server_error() -> Self
Shortcut for 500 Internal Server Error.
Sourcepub fn bad_gateway() -> Self
pub fn bad_gateway() -> Self
Shortcut for 502 Bad Gateway.
Shortcut for 503 Service Unavailable.
Sourcepub fn protocal(self, protocal: HttpVersion) -> Self
pub fn protocal(self, protocal: HttpVersion) -> Self
Set the HTTP protocol version (defaults to 1.1).
Sourcepub fn headers(self, headers: HashMap<HeaderKey, HeaderValue>) -> Self
pub fn headers(self, headers: HashMap<HeaderKey, HeaderValue>) -> Self
Set the response headers.
Sourcepub fn get_mut_headers(
&mut self,
) -> Option<&mut HashMap<HeaderKey, HeaderValue>>
pub fn get_mut_headers( &mut self, ) -> Option<&mut HashMap<HeaderKey, HeaderValue>>
Get a mutable reference to the headers (if present).
Sourcepub fn build(self) -> HttpResponse
pub fn build(self) -> HttpResponse
Finalize the builder and return a constructed HttpResponse.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HttpResponseBuilder
impl RefUnwindSafe for HttpResponseBuilder
impl Send for HttpResponseBuilder
impl Sync for HttpResponseBuilder
impl Unpin for HttpResponseBuilder
impl UnsafeUnpin for HttpResponseBuilder
impl UnwindSafe for HttpResponseBuilder
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