Spaces:
Runtime error
Runtime error
File size: 1,078 Bytes
eee346e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
"""API route definitions."""
from dataclasses import dataclass
from typing import List, Optional
@dataclass
class RouteConfig:
"""Configuration for an API route."""
path: str
methods: List[str]
description: str
version: Optional[str] = "v1"
# Example route configurations
ROUTES = [
RouteConfig(
path="/api/v1/health",
methods=["GET"],
description="Health check endpoint",
),
RouteConfig(
path="/api/v1/metrics",
methods=["GET"],
description="Application metrics endpoint",
),
]
def get_route_config(path: str) -> Optional[RouteConfig]:
"""Get route configuration by path.
Args:
path: The API route path
Returns:
Optional[RouteConfig]: The route configuration if found, None otherwise
"""
return next((route for route in ROUTES if route.path == path), None)
def list_routes() -> List[RouteConfig]:
"""List all available API routes.
Returns:
List[RouteConfig]: List of all route configurations
"""
return ROUTES |