rule

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrDuplicate = errors.Value("duplicate rule")
)

Variables

This section is empty.

Functions

func Register

func Register(r ...Registrar) error

Register registers all rules internally

Types

type Handler

type Handler interface {
	Valid() error
	ApplyRule(r *http.Request)
}

Handler is an interface to define the logic to ApplyRule to incoming request

type Handlers

type Handlers []Handler

Handlers is a type to implement UnmarshalJSON method every time a new rule is imeplemented, it needs to be added to append method

func (*Handlers) UnmarshalJSON

func (h *Handlers) UnmarshalJSON(p []byte) error

UnmarshalJSON overrides and decode rule handler configuration based on name

type PathReplace

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

func (*PathReplace) ApplyRule

func (p *PathReplace) ApplyRule(r *http.Request)

func (*PathReplace) Valid

func (p *PathReplace) Valid() error

type PathReplaceRegistry

type PathReplaceRegistry struct{}

func (*PathReplaceRegistry) CreateHandler

func (p *PathReplaceRegistry) CreateHandler() Handler

func (*PathReplaceRegistry) Name

func (p *PathReplaceRegistry) Name() string

type Registrar

type Registrar interface {
	Name() string
	CreateHandler() Handler
}

Jump to

Keyboard shortcuts

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