macro_rules! status {
($status:expr, { $($json:tt)* }) => { ... };
($status:expr) => { ... };
($status:expr, [ $( ($key:expr, $value:expr) ),* $(,)? ]) => { ... };
($status:expr, $var:ident) => { ... };
($status:expr, $body:expr, [ $( ($key:expr, $value:expr) ),* $(,)? ]) => { ... };
($status:expr, $fmt:tt) => { ... };
($status:expr, $body:expr) => { ... };
($status:expr, $($fmt:tt)*) => { ... };
}Expand description
Produces a response with specified StatusCode with plain text or JSON body
§Examples
§Without body
use volga::status;
status!(404);§plain/text body
use volga::status;
status!(401, "Unauthorized!");§JSON body
use volga::status;
use serde::Serialize;
#[derive(Serialize)]
struct ErrorMessage {
error: String
}
let error = ErrorMessage { error: "some error message".into() };
status!(401, error);