pub struct Response {
pub status_code: u16,
pub headers: HashMap<String, String>,
pub body: String,
pub is_base64_encoded: bool,
}Expand description
HTTP Response builder
Fields§
§status_code: u16§headers: HashMap<String, String>§body: String§is_base64_encoded: boolImplementations§
Source§impl Response
impl Response
Sourcepub fn json_body<T: Serialize>(self, body: &T) -> Self
pub fn json_body<T: Serialize>(self, body: &T) -> Self
Set response body from serializable object
Sourcepub fn from_json_value(value: Value) -> Self
pub fn from_json_value(value: Value) -> Self
Create Response from JSON value (for controller compatibility) Expects format: { statusCode: number, headers: object, body: any }
Sourcepub fn no_content() -> Self
pub fn no_content() -> Self
204 No Content response
Sourcepub fn bad_request(message: &str) -> Self
pub fn bad_request(message: &str) -> Self
400 Bad Request response
401 Unauthorized response
Sourcepub fn method_not_allowed(message: &str) -> Self
pub fn method_not_allowed(message: &str) -> Self
405 Method Not Allowed response
Sourcepub fn internal_error(message: &str) -> Self
pub fn internal_error(message: &str) -> Self
500 Internal Server Error response
Sourcepub fn cors_preflight() -> Self
pub fn cors_preflight() -> Self
CORS preflight response
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Response
impl<'de> Deserialize<'de> for Response
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
impl<B> IntoFunctionResponse<B, Body> for Bwhere
B: Serialize,
Source§fn into_response(self) -> FunctionResponse<B, Body>
fn into_response(self) -> FunctionResponse<B, Body>
Convert the type into a FunctionResponse.