pub struct Response {
pub code: StatusCode,
pub content_type: ContentType,
pub content: String,
}
Expand description
Simple server response structure
Fields§
§code: StatusCode
Response code
content_type: ContentType
Response content type
content: String
Response body
Implementations§
Source§impl Response
impl Response
Sourcepub fn ok<T: Into<String>>(response: T) -> Self
pub fn ok<T: Into<String>>(response: T) -> Self
Create a response with given body and 200 OK status code.
Sourcepub fn internal_error() -> Self
pub fn internal_error() -> Self
Create a response for internal error.
Sourcepub fn host_not_allowed() -> Self
pub fn host_not_allowed() -> Self
Create a response for not allowed hosts.
Sourcepub fn unsupported_content_type() -> Self
pub fn unsupported_content_type() -> Self
Create a response for unsupported content type.
Sourcepub fn method_not_allowed() -> Self
pub fn method_not_allowed() -> Self
Create a response for disallowed method used.
Sourcepub fn invalid_cors() -> Self
pub fn invalid_cors() -> Self
CORS invalid
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe 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