Open KaneTW opened 6 years ago
why you don't put RateLimit
before "minor"
capture and treat it as all api endpoints share this rate limiter?
EDIT which might be good idea, as I don't recall too many API with granular per-resource rate limiting.
I need /foo/bar/:id/:minor
to be a distinct bin than /foo/bar/:id
.
let me think a bit.
PathPiece
RateLimit
Capture' '[RateLimiterIgnored] "minor" :> RateLimit :> ...
RateLimit
in this settingFor now, I'd suggest to name the bins explicitly: RateLimit "/foo/bar/:id"
.
I'll probably go for something like
type RateLimitedAPI = "foo" :> "bar" :> Capture "id" Int :> RateLimit "minor" :> Capture "minor" Int :> Post '[JSON] Foo
and use the currently constructed Request
path + the type-level symbol as a bin.
Humm. I need to query my MonadRateLimit
whether a request can be performed or not, but
Request
has no field for user dataI can use a custom header and populate it with the bin name, for now, but it's not particularly elegant.
I'm currently writing an implementation of rate limiting for
servant-client
, and it'd be very useful to have access to the current URL path as e.g. a[PathPiece]
whereso that I can properly group rate limiting bins by specific
Capture
s.Ideally, I'd be able to do something like