Struct jsonrpc_http_server::Response
source · [−]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
sourceimpl 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 RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more