33 lines
803 B
Rust
33 lines
803 B
Rust
pub mod monitor;
|
|
|
|
use rocket_dyn_templates::Template;
|
|
|
|
use rocket::response::{Redirect, Responder};
|
|
use rocket::serde::json::{Value, json};
|
|
use rocket::serde::{Serialize};
|
|
|
|
// HELPER FUNCTIONS
|
|
|
|
pub fn build_json_response(
|
|
status: String,
|
|
data: Option<Value>,
|
|
msg: Option<String>,
|
|
) -> Value {
|
|
json!({ "status": status, "data": data, "msg": msg })
|
|
}
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct FlashContext {
|
|
pub flash_name: Option<String>,
|
|
pub flash_msg: Option<String>,
|
|
}
|
|
|
|
|
|
/// A helper enum which allows routes to either return a Template or a Redirect
|
|
/// from: https://github.com/SergioBenitez/Rocket/issues/253#issuecomment-532356066
|
|
#[allow(clippy::large_enum_variant)]
|
|
#[derive(Debug, Responder)]
|
|
pub enum TemplateOrRedirect {
|
|
Template(Template),
|
|
Redirect(Redirect),
|
|
} |