pub mod granter;
pub mod mdk_shield;
pub mod registration_page;
pub mod takumi_api;

use axum::{Json, Router};
use serde_json::json;

#[macro_export]
macro_rules! routes {
    ($($path:tt $method:ident($handler:expr);)*) => {
        pub fn make_routes() -> ::axum::Router<crate::SdkState> {
            Router::new()
            $(
                .route($path, ::axum::routing::$method($handler))
            )*
        }
    };
}

fn fail_json(retcode: i32, message: &str) -> Json<serde_json::Value> {
    Json(json! ({
        "retcode": retcode,
        "message": message
    }))
}
