middleware

package
v0.0.0-...-62f0cde Latest Latest
Warning

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

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

Documentation

Overview

Package middleware defines possible middleware that can be used by router

Index

Constants

View Source
const (
	// ExpiryTime defines how long before the user got deleted
	ExpiryTime time.Duration = 3 * time.Minute
	// RefreshRate deinfes how often we check the map for expired user
	RefreshRate time.Duration = 1 * time.Minute
	// AvgRate defines the average of r tokens (one) per seconds
	AvgRate rate.Limit = 1
	// MaxRate defines the maximum of b tokens (five) in single `burst`
	MaxRate int = 3
)

Variables

This section is empty.

Functions

func Auth

func Auth(req http.Handler) http.Handler

Auth ensures endpoints cannot be access from unauthorized source

func CORS

func CORS(req http.Handler) http.Handler

CORS handles cors request

func RateLimiter

func RateLimiter(req http.Handler) http.Handler

RateLimiter is the middleware to prevent a single IP to overload the server by performing too many req

Types

type Visitor

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

Visitor defines rate limiter for each visitor and the last time the visitor was seen

Jump to

Keyboard shortcuts

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