from fastapi import APIRouter, Request

HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]

default_router = APIRouter()

@default_router.api_route("/{full_path:path}", methods=HTTP_METHODS, include_in_schema=False)
async def default_handler(request: Request, full_path: str, handler_name: str = "default"):
    try:
        body = await request.json()
    except:
        body = None
    return dict(
        handler_name=handler_name,
        path=full_path,
        method=request.method,
        query=dict(request.query_params),
        headers=dict(request.headers),
        body=body
    )
