rule

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const AppendPathName = "AppendPath"
View Source
const ReplacePathName = "ReplacePath"

Variables

View Source
var Empty = []Middleware{}

Functions

func Chain

func Chain(next http.Handler, rules ...Middleware) http.Handler

func NewAppendPath

func NewAppendPath(begin, end string) struct {
	Type string `json:"type"`
	Args any    `json:"args"`
}

func NewRateLimiter

func NewRateLimiter(requestLimit int, windowDuration time.Duration) struct {
	Type string `json:"type"`
	Args any    `json:"args"`
}

func NewReplacePath

func NewReplacePath(search string, replace string, times int) struct {
	Type string `json:"type"`
	Args any    `json:"args"`
}

Types

type AppendPath

type AppendPath struct {
	Begin string `json:"begin"`
	End   string `json:"end"`
}

func (*AppendPath) IsCachable

func (a *AppendPath) IsCachable() bool

func (*AppendPath) Process

func (a *AppendPath) Process(next http.Handler) http.Handler

func (*AppendPath) UpdateMiddelware

func (a *AppendPath) UpdateMiddelware(newImpl Middleware) Middleware

type BuilderFunc

type BuilderFunc func(raw json.RawMessage) (Middleware, error)

type Middleware

type Middleware interface {
	Process(next http.Handler) http.Handler
	IsCachable() bool
	UpdateMiddelware(newImpl Middleware) Middleware
}

type RateLimiter

type RateLimiter struct {
	RequestLimit   int            `json:"request_limit"`
	WindowDuration WindowDuration `json:"window_duration"`
	// contains filtered or unexported fields
}

func (*RateLimiter) IsCachable

func (r *RateLimiter) IsCachable() bool

func (*RateLimiter) Process

func (r *RateLimiter) Process(next http.Handler) http.Handler

func (*RateLimiter) UpdateMiddelware

func (r *RateLimiter) UpdateMiddelware(newImpl Middleware) Middleware

type RegisterFunc

type RegisterFunc func(map[string]BuilderFunc) error

func RegisterAppendPath

func RegisterAppendPath() RegisterFunc

func RegisterRateLimiter

func RegisterRateLimiter() RegisterFunc

func RegisterReplacePath

func RegisterReplacePath() RegisterFunc

type ReplacePath

type ReplacePath struct {
	Search  string `json:"search"`
	Replace string `json:"replace"`
	Times   int    `json:"times"`
}

func (*ReplacePath) IsCachable

func (p *ReplacePath) IsCachable() bool

func (*ReplacePath) Process

func (p *ReplacePath) Process(next http.Handler) http.Handler

func (*ReplacePath) UpdateMiddelware

func (p *ReplacePath) UpdateMiddelware(newImpl Middleware) Middleware

type WindowDuration

type WindowDuration struct {
	time.Duration
}

func (WindowDuration) MarshalJSON

func (d WindowDuration) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for WindowDuration.

func (*WindowDuration) UnmarshalJSON

func (d *WindowDuration) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for WindowDuration.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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