rule

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT 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 NewAppendPath

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

func NewRateLimiter added in v1.2.0

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 added in v1.2.0

func (a *AppendPath) IsCachable() bool

func (*AppendPath) Process

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

func (*AppendPath) UpdateMiddelware added in v1.2.0

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 added in v1.2.0

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

func (*RateLimiter) IsCachable added in v1.2.0

func (r *RateLimiter) IsCachable() bool

func (*RateLimiter) Process added in v1.2.0

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

func (*RateLimiter) UpdateMiddelware added in v1.2.0

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

type RegisterFunc

type RegisterFunc func(map[string]BuilderFunc) error

func RegisterAppendPath

func RegisterAppendPath() RegisterFunc

func RegisterRateLimiter added in v1.2.0

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 added in v1.2.0

func (p *ReplacePath) IsCachable() bool

func (*ReplacePath) Process

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

func (*ReplacePath) UpdateMiddelware added in v1.2.0

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

type WindowDuration added in v1.2.0

type WindowDuration struct {
	time.Duration
}

func (WindowDuration) MarshalJSON added in v1.2.0

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

MarshalJSON implements the json.Marshaler interface for WindowDuration.

func (*WindowDuration) UnmarshalJSON added in v1.2.0

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