2025-03-22 10:16:54 +00:00

35 lines
819 B
Python

from fastapi import APIRouter, HTTPException
import uuid
routes = [] # In-memory storage
router = APIRouter()
@router.post("/route")
async def create_route(
name: str = "new_route",
path: str = "/example",
method: str = "GET"
):
"""Demo route creation endpoint"""
if any(r["path"] == path for r in routes):
raise HTTPException(status_code=400, detail="Route path already exists")
route_id = str(uuid.uuid4())
routes.append({
"id": route_id,
"name": name,
"path": path,
"method": method,
"disabled": False
})
return {
"message": "Route created successfully",
"route_id": route_id,
"name": name,
"next_steps": [
"Configure route handlers",
"Set up middleware"
]
}