Dai Dao e109f7e58e
refactor : Improve frontend setup doc and locale error (#6850)
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
2025-02-21 23:14:44 +01:00

35 lines
932 B
Python

from fastapi import (
APIRouter,
HTTPException,
Request,
status,
)
app = APIRouter(prefix='/api/conversations/{conversation_id}')
@app.route('/security/{path:path}', methods=['GET', 'POST', 'PUT', 'DELETE'])
async def security_api(request: Request):
"""Catch-all route for security analyzer API requests.
Each request is handled directly to the security analyzer.
Args:
request (Request): The incoming FastAPI request object.
Returns:
Any: The response from the security analyzer.
Raises:
HTTPException: If the security analyzer is not initialized.
"""
if not request.state.conversation.security_analyzer:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail='Security analyzer not initialized',
)
return await request.state.conversation.security_analyzer.handle_api_request(
request
)