Skip to content

Commit

Permalink
请求过于频繁的异常处理
Browse files Browse the repository at this point in the history
  • Loading branch information
putianyi889 committed Jun 30, 2024
1 parent c1442b4 commit 04da0d2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion back_end/saolei/saolei/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

ROOT_URLCONF = "saolei.urls"

RATELIMIT_VIEW = "utils.ratelimited"
RATELIMIT_VIEW = "utils.response.ratelimited_error"

TEMPLATES = [
{
Expand Down
4 changes: 4 additions & 0 deletions back_end/saolei/utils/response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.http import HttpResponse

def ratelimited_error(request, exception):
return HttpResponse(status=429)
1 change: 1 addition & 0 deletions front_end/src/i18n/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export type LocaleConfig = LocaleMessage<VueMessageType> & {
InternalServerError: string,
NotFound: string,
PayloadTooLarge: string,
TooManyRequests: string,
UnsupportedMediaType: string,
},
show: string,
Expand Down
1 change: 1 addition & 0 deletions front_end/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const en = {
InternalServerError: 'Internal server error',
NotFound: 'Data not found',
PayloadTooLarge: 'Payload too large',
TooManyRequests: 'Too many requests',
UnsupportedMediaType: 'Unsupported file type',
},
show: 'Show',
Expand Down
1 change: 1 addition & 0 deletions front_end/src/i18n/locales/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const zhCn = {
InternalServerError: '后端发生错误',
NotFound: '找不到数据',
PayloadTooLarge: '文件过大',
TooManyRequests: '请求过于频繁',
UnsupportedMediaType: '不支持的文件类型',
},
show: '显示',
Expand Down
1 change: 1 addition & 0 deletions front_end/src/utils/system/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const notificationMessage: { [code: number]: string} = {
404: 'common.response.NotFound',
413: 'common.response.PayloadTooLarge',
415: 'common.response.UnsupportedMediaType',
429: 'common.response.TooManyRequests',
500: 'common.response.InternalServerError',
};

Expand Down

0 comments on commit 04da0d2

Please sign in to comment.