gin

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

HandlerFactory is the out-of-the-box basic ratelimit handler factory using the default krakend endpoint handler for the gin router

Functions

func IPTokenExtractor

func IPTokenExtractor(c *gin.Context) string

IPTokenExtractor extracts the IP of the request

func NewRateLimiterMw

func NewRateLimiterMw(next krakendgin.HandlerFactory) krakendgin.HandlerFactory

NewRateLimiterMw builds a rate limiting wrapper over the received handler factory.

Types

type EndpointMw

type EndpointMw func(gin.HandlerFunc) gin.HandlerFunc

EndpointMw is a function that decorates the received handlerFunc with some rateliming logic

func NewEndpointRateLimiterMw

func NewEndpointRateLimiterMw(tb rate.Limiter) EndpointMw

NewEndpointRateLimiterMw creates a simple ratelimiter for a given handlerFunc

func NewHeaderLimiterMw

func NewHeaderLimiterMw(header string, maxRate float64, capacity int) EndpointMw

NewHeaderLimiterMw creates a token ratelimiter using the value of a header as a token

func NewIpLimiterMw

func NewIpLimiterMw(maxRate float64, capacity int) EndpointMw

NewHeaderLimiterMw creates a token ratelimiter using the IP of the request as a token

func NewTokenLimiterMw

func NewTokenLimiterMw(tokenExtractor TokenExtractor, limiterStore krakendrate.LimiterStore) EndpointMw

NewTokenLimiterMw returns a token based ratelimiting endpoint middleware with the received TokenExtractor and LimiterStore

type TokenExtractor

type TokenExtractor func(*gin.Context) string

TokenExtractor defines the interface of the functions to use in order to extract a token for each request

func HeaderTokenExtractor

func HeaderTokenExtractor(header string) TokenExtractor

HeaderTokenExtractor returns a TokenExtractor that looks for the value of the designed header

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL