mod v0; mod v1; use { hyper::{ StatusCode, Request, header::HeaderValue, body::{ Incoming, }, }, serde_json::{ Value as Json, json, }, skytable::pool::ConnectionMgrTcp, bb8::Pool, std::sync::Arc, }; type DBPool = Arc>; pub async fn endpoint(req: Request, pool: DBPool) -> (String, StatusCode, HeaderValue) { let uri: &str = req.uri().path().as_ref(); let res: Json = match &uri[4..uri.len()] { "/test" => json!({"error": false, "msg": "test"}), x if x.starts_with("/v0/") => v0::api(req, pool.clone()).await, x if x.starts_with("/v1/") => v1::api(req, pool.clone()).await, _ => json!({"error": true, "msg": "No endpoint"}) }; let restype: HeaderValue = "application/json".parse().unwrap(); (res.to_string(), StatusCode::OK, restype) }