http

package
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowedOrigin added in v0.67.1

func AllowedOrigin(allowedOrigins []string) func(origin string) bool

func CORSOptions added in v0.67.1

func CORSOptions(config CORSConfig) cors.Options

func RemoteAddr

func RemoteAddr(r *http.Request) (string, error)

RemoteAddr collects possible remote addresses from a request.

Types

type CORSConfig added in v0.67.1

type CORSConfig struct {
	AllowedOrigins []string `long:"allowed-origins" description:"Allowed origins for CORS"`
	MaxAge         int      `long:"max-age" description:"Max age (in seconds) for preflight cache"`
}

CORSConfig represents the configuration for CORS.

type RateLimit

type RateLimit struct {
	// contains filtered or unexported fields
}

func NewRateLimit

func NewRateLimit(ctx context.Context, cfg RateLimitConfig) (*RateLimit, error)

func (*RateLimit) NewRequest

func (r *RateLimit) NewRequest(identifier, ip string) error

NewRequest returns nil if the rate has not been exceeded.

type RateLimitConfig

type RateLimitConfig struct {
	CoolDown encoding.Duration `long:"coolDown" description:"rate-limit duration, e.g. 10s, 1m30s, 24h0m0s"`

	AllowList []string `long:"allowList" description:"a list of ip/subnets, e.g. 10.0.0.0/8, 192.168.0.0/16"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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