Skip to content

Commit b85b289

Browse files
committed
tried to fix limiter exception
1 parent e4ba1d2 commit b85b289

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/paste/main.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
RedirectResponse,
1616
JSONResponse,
1717
)
18+
from starlette.requests import Request
19+
from starlette.responses import Response
20+
from typing import Callable, Awaitable, List, Optional
1821
import shutil
1922
import os
2023
import json
@@ -30,9 +33,8 @@
3033
from pygments.lexers import get_lexer_by_name, guess_lexer
3134
from pygments.formatters import HtmlFormatter
3235
from pygments.util import ClassNotFound
33-
from typing import List, Optional
3436
from . import __version__, __author__, __contact__, __url__
35-
from .schema import PasteCreate, PasteDetails, PasteResponse
37+
from .schema import PasteCreate, PasteResponse, PasteDetails
3638

3739
description: str = "paste.py 🐍 - A pastebin written in python."
3840

@@ -51,7 +53,11 @@
5153
redoc_url=None,
5254
)
5355
app.state.limiter = limiter
54-
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
56+
57+
async def rate_limit_exceeded_handler(request: Request, exc: RateLimitExceeded) -> Response:
58+
return await _rate_limit_exceeded_handler(request, exc)
59+
60+
app.add_exception_handler(RateLimitExceeded, rate_limit_exceeded_handler)
5561

5662
origins: List[str] = ["*"]
5763

0 commit comments

Comments
 (0)