Struct direkuta::JsonBuilder
source · Expand description
A builder for JSON responses.
Implementations§
source§impl<T: Serialize + Send + Sync> JsonBuilder<T>
impl<T: Serialize + Send + Sync> JsonBuilder<T>
sourcepub fn errors(&mut self, messages: Vec<impl Into<String>>)
pub fn errors(&mut self, messages: Vec<impl Into<String>>)
Added an error message to the wrapper.
sourcepub fn code(&mut self, status: u16)
pub fn code(&mut self, status: u16)
Set the status code of the Json response.
This can be gotten with StatusCode.as_u16.
sourcepub fn with_code(self, status: u16) -> Self
pub fn with_code(self, status: u16) -> Self
Set the status code of the Json response.
This can be gotten with StatusCode.as_u16.
sourcepub fn status(&mut self, status: impl Into<String>)
pub fn status(&mut self, status: impl Into<String>)
Set the status string of the Json response.
This can be gotten with StatusCode.as_str.
sourcepub fn with_status(self, status: &str) -> Self
pub fn with_status(self, status: &str) -> Self
Set the status string of the Json response.
This can be gotten with StatusCode.as_str.