https://kotlinlang.org logo
#ktor
Title
# ktor
t

Tech

01/02/2023, 1:53 PM
With ktor rate limiting is it possible to ignore rate limiting for authorized requests and public ones get rate limited?
r

Rustam Siniukov

01/02/2023, 2:03 PM
something like this should work
Copy code
requestKey { call -> 
  call.principal<MyUser>() ?: FreeUser
}

rateLimitter { call, key -> 
  if (key is FreeUser) RateLimiter.default(...) else RateLimiter.Unlimited 
}
t

Tech

01/02/2023, 2:03 PM
Ah gotcha, didn't know they provided those to use
thanks!
👍 1
5 Views