use std::str::FromStr; use rocket::response::status::BadRequest; use serde_json::json; pub mod context; pub mod assets; pub mod cache; pub mod api; pub fn to_uuid(id: &str) -> Result { uuid::Uuid::from_str(id).map_err(|_| no_uuid_error()) } type ApiError = BadRequest; type FallibleApiResponse = Result; pub fn no_uuid_error() -> ApiError { api_error("No valid UUID") } pub fn api_error(msg: &str) -> ApiError { BadRequest(json!({ "error": msg })) }