add basic rate limiting
This commit is contained in:
@ -2,7 +2,8 @@ import importlib
|
||||
import logging
|
||||
import traceback
|
||||
from typing import Optional, Union
|
||||
from fastapi import FastAPI
|
||||
from fastapi import FastAPI, Depends
|
||||
from fastapi_throttle import RateLimiter
|
||||
from fastapi.responses import JSONResponse
|
||||
from .constructors import (
|
||||
ValidArtistSearchRequest,
|
||||
@ -32,7 +33,9 @@ class LastFM(FastAPI):
|
||||
|
||||
for endpoint, handler in self.endpoints.items():
|
||||
app.add_api_route(
|
||||
f"/{endpoint}", handler, methods=["POST"], include_in_schema=True
|
||||
f"/{endpoint}", handler,
|
||||
methods=["POST"], include_in_schema=True,
|
||||
dependencies=[Depends(RateLimiter(times=2, seconds=2))]
|
||||
)
|
||||
|
||||
async def artist_by_name_handler(
|
||||
|
Reference in New Issue
Block a user