http

package
v0.75.8 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: AGPL-3.0 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 `description:"Allowed origins for CORS"                 long:"allowed-origins"`
	MaxAge         int      `description:"Max age (in seconds) for preflight cache" long:"max-age"`
}

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 `description:"rate-limit duration, e.g. 10s, 1m30s, 24h0m0s" long:"coolDown"`

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

Jump to

Keyboard shortcuts

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