feat: Refactor Dashboard template to extend base layout and improve structure feat: Enhance Parameter Input template with improved layout and feedback mechanisms feat: Update Scenario Form template to utilize base layout and improve user experience feat: Create base layout template for consistent styling across pages feat: Add Consumption, Costs, Equipment, Maintenance, Production, Reporting, and Simulations templates with placeholders for future functionality feat: Implement base header and footer partials for consistent navigation and footer across the application
17 lines
597 B
Python
17 lines
597 B
Python
from typing import Awaitable, Callable
|
|
|
|
from fastapi import HTTPException, Request, Response
|
|
|
|
MiddlewareCallNext = Callable[[Request], Awaitable[Response]]
|
|
|
|
async def validate_json(request: Request, call_next: MiddlewareCallNext) -> Response:
|
|
# Only validate JSON for requests with a body
|
|
if request.method in ("POST", "PUT", "PATCH"):
|
|
try:
|
|
# attempt to parse json body
|
|
await request.json()
|
|
except Exception:
|
|
raise HTTPException(status_code=400, detail="Invalid JSON payload")
|
|
response = await call_next(request)
|
|
return response
|