long2ice / fastapi-limiter

A request rate limiter for fastapi
https://github.com/long2ice/fastapi-limiter
Apache License 2.0
487 stars 53 forks source link

does't work on IIS #22

Open maxiaojunwolf opened 2 years ago

maxiaojunwolf commented 2 years ago

it works when i use uvicorn to start ther server,but HTTP 500 when i start it by IIS

maxiaojunwolf commented 2 years ago

the reason is:
the 'on_startup' function does't be called on IIS,so the "await FastAPILimiter.init(cache)"also does't be called

my solution: try to call FastAPILimiter.init on server starting, FastAPILimiter.redis = cache FastAPILimiter.prefix = "fastapi-limiter" FastAPILimiter.identifier = default_identifier FastAPILimiter.callback = default_callback FastAPILimiter.lua_sha = 'a3f9e982197e9e887f6b5dcb7ec273863bb83aad' (use uvicorn start first get the SHA value,otherwise you need an async function,actual you can use this value direct)