schemas_v1_api_index - OmniCloudOrg/OmniOrchestrator GitHub Wiki
Path: src/schemas/v1/api/index.rs
- struct RouteInfo
- struct RoutesResponse
- struct RoutesCollection
- fn new
- fn add_route
- fn get_routes
- fn collect_routes
- fn routes_ui
pub struct RouteInfo {
/// Path of the route
path: String,
/// HTTP methods supported by the route
methods: Vec<String>,
}
Route information structure for API documentation
pub struct RoutesResponse {
/// List of all available routes and their methods
routes: Vec<RouteInfo>,
}
Response structure for routes listing endpoint
pub struct RoutesCollection {
routes: Vec<RouteInfo>,
}
Routes collection that will be populated during startup
pub fn new() -> Self {
Self { routes: Vec::new() }
}
pub fn add_route(&mut self, path: String, method: String) {
// ... function body
}
pub fn add_route(&mut self, path: String, method: String) {
// Check if the route already exists
if let Some(route) = self.routes.iter_mut().find(|r| r.path == path) {
// ... function body
}
pub fn get_routes(&self) -> Vec<RouteInfo> {
self.routes.clone()
}
}
/// Global singleton instance of the routes collection
/// Stores information about all registered API routes
lazy_static! {
// ... function body
}
pub fn collect_routes(rocket: &Rocket<Build>) {
let mut routes_collection = ROUTES_COLLECTION.lock().unwrap();
pub fn routes_ui() -> content::RawHtml<String> {
let routes_collection = ROUTES_COLLECTION.lock().unwrap();
Routes listing endpoint providing HTML representation of routes