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