pub struct Response {
pub code: StatusCode,
pub content_type: HeaderValue,
pub content: String,
}
Expand description
Simple server response structure
Fields§
§code: StatusCode
Response code
content_type: HeaderValue
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<T: Into<String>>(msg: T) -> Self
pub fn internal_error<T: Into<String>>(msg: T) -> Self
Create a response for plaintext internal error.
Create a json response for service unavailable.
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_allow_origin() -> Self
pub fn invalid_allow_origin() -> Self
CORS invalid
Sourcepub fn invalid_allow_headers() -> Self
pub fn invalid_allow_headers() -> Self
CORS header invalid
Sourcepub fn bad_request<S: Into<String>>(msg: S) -> Self
pub fn bad_request<S: Into<String>>(msg: S) -> Self
Create a response for bad request
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