jsonrpc_http_server

Struct 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§

Source§

impl Response

Source

pub fn empty() -> Self

Create a response with empty body and 200 OK status code.

Source

pub fn ok<T: Into<String>>(response: T) -> Self

Create a response with given body and 200 OK status code.

Source

pub fn internal_error<T: Into<String>>(msg: T) -> Self

Create a response for plaintext internal error.

Source

pub fn service_unavailable<T: Into<String>>(msg: T) -> Self

Create a json response for service unavailable.

Source

pub fn host_not_allowed() -> Self

Create a response for not allowed hosts.

Source

pub fn unsupported_content_type() -> Self

Create a response for unsupported content type.

Source

pub fn method_not_allowed() -> Self

Create a response for disallowed method used.

Source

pub fn invalid_allow_origin() -> Self

CORS invalid

Source

pub fn invalid_allow_headers() -> Self

CORS header invalid

Source

pub fn bad_request<S: Into<String>>(msg: S) -> Self

Create a response for bad request

Source

pub fn too_large<S: Into<String>>(msg: S) -> Self

Create a response for too large (413)

Trait Implementations§

Source§

impl Debug for Response

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Response> for RequestMiddlewareAction

Source§

fn from(o: Response) -> Self

Converts to this type from the input type.
Source§

impl From<Response> for Response<Body>

Source§

fn from(res: Response) -> Response<Body>

Converts from a jsonrpc Response to a hyper::Response

§Panics

Panics if the response cannot be converted due to failure to parse body content.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.