pub struct Response {
pub status: StatusCode,
pub headers: HeaderMap,
pub body: Body,
}Expand description
An HTTP response.
Fields§
§status: StatusCode§headers: HeaderMap§body: BodyImplementations§
Source§impl Response
impl Response
pub fn new(status: StatusCode, body: Body) -> Response
pub fn text(body: impl Into<String>) -> Response
pub fn html(body: impl Into<String>) -> Response
pub fn bytes(body: impl Into<Bytes>) -> Response
Sourcepub fn permanent_redirect(location: &str) -> Response
pub fn permanent_redirect(location: &str) -> Response
Permanent redirect (308).
pub fn redirect_with(location: &str, status: StatusCode) -> Response
pub fn not_found() -> Response
pub fn with_status(self, code: u16) -> Response
Sourcepub fn with_header(self, name: &str, value: &str) -> Response
pub fn with_header(self, name: &str, value: &str) -> Response
Set a header. Invalid names or values (e.g. containing CR/LF) are rejected, which prevents header injection; they are logged and dropped.
pub fn set_header(&mut self, name: &str, value: &str) -> bool
pub fn append_header(&mut self, name: &str, value: &str) -> bool
pub fn with_content_type(self, ct: &'static str) -> Response
pub fn with_cache_control(self, value: &str) -> Response
Add a cookie to the response.
pub fn header(&self, name: &str) -> Option<&str>
Trait Implementations§
Source§impl IntoResponse for Response
impl IntoResponse for Response
fn into_response(self) -> Response
Auto Trait Implementations§
impl !Freeze for Response
impl !RefUnwindSafe for Response
impl !Sync for Response
impl !UnwindSafe for Response
impl Forget for Response
impl Move for Response
impl Send for Response
impl Unpin for Response
impl UnsafeUnpin for Response
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