request

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cros

func Cros(w http.ResponseWriter, req *http.Request)

func GetIp

func GetIp(req *http.Request) (string, error)

获取IP。这个只根据remoteaddr获取的不是很准确 要么nginx把IP转发到这个上面,要么继续完善各种可能从而获取准确的IP

func GetToken

func GetToken(req *http.Request) (string, error)

func Meta

func Meta(ctx context.Context, r *http.Request) metadata.MD

Types

type Limiter

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

func NewLimiter

func NewLimiter(p Policy) *Limiter

func (*Limiter) Allow

func (e *Limiter) Allow() bool

func (*Limiter) Visits

func (e *Limiter) Visits() uint64

type Policy

type Policy struct {
	Name   string
	Ip, Tk string
	R      rate.Limit
	B      int
}

type VisitorLimiter

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

func NewVisitorLimiter

func NewVisitorLimiter() *VisitorLimiter

func (*VisitorLimiter) Allow

func (e *VisitorLimiter) Allow() bool

func (*VisitorLimiter) NewIpLimiter

func (e *VisitorLimiter) NewIpLimiter() (*Limiter, error)

func (*VisitorLimiter) NewTokenLimiter

func (e *VisitorLimiter) NewTokenLimiter() (*Limiter, error)

func (*VisitorLimiter) SetPolicy

func (e *VisitorLimiter) SetPolicy(p Policy) *VisitorLimiter

func (*VisitorLimiter) SetRequest

func (e *VisitorLimiter) SetRequest(req *http.Request) *VisitorLimiter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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