filter

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package linkFilter for Toolkits

Index

Constants

View Source
const (
	AnySymbol        = "*"
	Terminator       = "*"
	DefaultDelimiter = ":"
)

Variables

This section is empty.

Functions

func IsTerminated

func IsTerminated(paths []string) bool

func LinkTerminator

func LinkTerminator(l *Link)

func OnlyTerminator

func OnlyTerminator(paths []string) bool

func PathTerminator

func PathTerminator(paths []string) []string

Types

type Filter

type Filter interface {
	Skip(req *http.Request) bool
	Denied(method, path string) bool
	Allowed(method, path string) bool
	AllowStrings(method string) []string
	DenyStrings(method string) []string
}

func NewFilter

func NewFilter(ss ...Setting) Filter

func NewStringFilter

func NewStringFilter(ss ...Setting) Filter
type Link struct {
	Path string
	Subs []*Link
}
func NewLink(path string) *Link

func (*Link) AddSub

func (l *Link) AddSub(s *Link)

func (*Link) AddSubs

func (l *Link) AddSubs(src ...*Link)

func (*Link) Contains

func (l *Link) Contains(paths []string) bool

func (*Link) Equal

func (l *Link) Equal(path string) bool

func (*Link) Has

func (l *Link) Has(name string) bool

func (*Link) HasSubs

func (l *Link) HasSubs() bool

func (*Link) IsEnd

func (l *Link) IsEnd() bool

func (*Link) String

func (l *Link) String() string

func (*Link) StringList

func (l *Link) StringList(parent string) []string

type Linker

type Linker interface {
	Contains(paths []string) bool
	Equal(path string) bool
	Has(name string) bool
	String() string
}

type MethodType

type MethodType uint8
const (
	MethodAny MethodType = iota
	MethodGet
	MethodPut
	MethodDelete
	MethodConnect
	MethodHead
	MethodPost
	MethodPatch
	MethodTrace
	MethodOptions
	MethodTypeMax
)

func MethodIndex

func MethodIndex(method string) MethodType

func (MethodType) String

func (i MethodType) String() string

type Option

type Option struct {
	Delimiter string
	SkipAny   bool
	DenyOff   bool
	AllowOff  bool
	Allows    []string
	Denies    []string
}

type Setting

type Setting = func(*Option)

func DisableAllow

func DisableAllow() Setting

func DisableDeny

func DisableDeny() Setting

func SkipAny

func SkipAny() Setting

SkipAny strong rule check. After this function is enabled, wildcard method match check is skipped

func WithAllows

func WithAllows(allows ...string) Setting

func WithDelimiter

func WithDelimiter(delimiter string) Setting

func WithDenies

func WithDenies(denies ...string) Setting

Jump to

Keyboard shortcuts

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