32 lines
723 B
Python
32 lines
723 B
Python
from fastapi import APIRouter, HTTPException
|
|
|
|
routes = [] # In-memory storage
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/route")
|
|
async def create_route(
|
|
name: str = "default_route",
|
|
path: str = "/default",
|
|
method: str = "GET"
|
|
):
|
|
"""Demo route creation endpoint"""
|
|
if any(r["path"] == path for r in routes):
|
|
raise HTTPException(status_code=400, detail="Route already exists")
|
|
|
|
route = {
|
|
"name": name,
|
|
"path": path,
|
|
"method": method,
|
|
"active": True
|
|
}
|
|
routes.append(route)
|
|
|
|
return {
|
|
"message": "Route created successfully",
|
|
"route": name,
|
|
"features": {
|
|
"rate_limit": 100,
|
|
"expires_in": 3600
|
|
}
|
|
} |