Update code in endpoints/route.post.py
This commit is contained in:
parent
7f8f367386
commit
5a3a6165fe
@ -0,0 +1,35 @@
|
|||||||
|
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"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user