feat: harden phase 3 api security

This commit is contained in:
QiuSW
2026-07-03 10:34:37 +08:00
parent 1c5aa7845d
commit 0168aa30ba
19 changed files with 540 additions and 46 deletions
+13
View File
@@ -0,0 +1,13 @@
from __future__ import annotations
from rest_framework.exceptions import Throttled
from rest_framework.views import exception_handler
from apps.api.errors import api_error
def api_exception_handler(exc, context):
response = exception_handler(exc, context)
if response is not None and isinstance(exc, Throttled):
response.data = api_error("rate_limited", "请求过于频繁,请稍后再试")
return response