Files
Roman Perekhod c66464cab6 fix: [OCISDEV-825] Rate-limit the exportPersonalData endpoint (#12519)
* fix: Rate-limit the exportPersonalData endpoint

* fix: the RequreSelfUserID validation middleware added
2026-07-08 14:57:44 +02:00

33 lines
626 B
Go

package httprate
import "context"
type ctxKey int
const (
incrementKey ctxKey = iota
requestLimitKey
)
func WithIncrement(ctx context.Context, value int) context.Context {
return context.WithValue(ctx, incrementKey, value)
}
func getIncrement(ctx context.Context) int {
if value, ok := ctx.Value(incrementKey).(int); ok {
return value
}
return 1
}
func WithRequestLimit(ctx context.Context, value int) context.Context {
return context.WithValue(ctx, requestLimitKey, value)
}
func getRequestLimit(ctx context.Context) int {
if value, ok := ctx.Value(requestLimitKey).(int); ok {
return value
}
return 0
}