middleware

package
v0.0.0-...-65594e8 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 6 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 = 2 * time.Minute
	// AvgRate defines the limit of average token comsumption
	AvgRate rate.Limit = 1
	// MaxRate defines the limit of spike token consumption
	MaxRate int = 1
)

Variables

This section is empty.

Functions

func LogRoute

func LogRoute(next http.Handler) http.Handler

LogRoute prettyprints requested routes

GET /v1/<endpoints> -> r.RequestURI
LogRoute() -> [GET] : 127.0.0.1/api/v1/<endpoints>

func RateLimit

func RateLimit(req http.HandlerFunc) http.HandlerFunc

RateLimit 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