OPEN API 서비스등을 한다면..? 필요할지도...
https://www.django-rest-framework.org/api-guide/throttling/
settings.py
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_CLASSES' : [
'rest_framework.throttling.UserRateThrottle',
],
'DEFAULT_THROTTLE_RATES' : {
'user' : '10/day',
# Rate는 숫자/간격으로 간격은 첫글자만 사용.
# d,day,ddd 모두 Day, s,m,h,d가 가능
}
}
views.py
from rest_framework.throttling import AnonRateThrottle
class PostViewSet(ViewSet):
throttle_classes = AnonRateThrottle
429 Too many Requests
응답.
예외 메시지에 API 활용이 가능한 시점을 알려준다.