Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(configFn ConfigFunc) goyave.Middleware

New initializes new a rate limiter middleware

Types

type Config

type Config struct {
	// Unique identifier for requestors. Can be userID or IP
	// Defaults to Remote Address if it is empty
	ClientID interface{}

	// Duration or time taken until the quota expires and renews
	QuotaDuration time.Duration

	// Maximum number of requests in a client can send
	RequestQuota int
}

Config for setting configuration for the limiter middleware

type ConfigFunc

type ConfigFunc func(request *goyave.Request) Config

ConfigFunc acts as a factory for Config structs