mux

package module
v0.0.0-...-f4affc0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MethodToStr

func MethodToStr(method Method) string

func Segments

func Segments(url string) iter.Seq2[string, bool]

Types

type Leaf

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

func (*Leaf) Get

func (l *Leaf) Get(method Method) http.Handler

func (*Leaf) Set

func (l *Leaf) Set(method Method, handler http.Handler) error

func (*Leaf) String

func (l *Leaf) String() string

type Method

type Method uint8
const (
	ANY Method = 1 << iota
	GET
	POST
	PUT
	PATCH
	DELETE
	HEAD
	OPTIONS
)

func MethodToUInt8

func MethodToUInt8(method string) Method

func SplitPattern

func SplitPattern(pattern string) (methodNum Method, url string, err error)

type Multiplexer

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

func NewMultiplexer

func NewMultiplexer() *Multiplexer

func (*Multiplexer) Dump

func (m *Multiplexer) Dump()

func (*Multiplexer) Handle

func (m *Multiplexer) Handle(pattern string, handler http.Handler)

func (*Multiplexer) HandleFunc

func (m *Multiplexer) HandleFunc(pattern string, handler func(w http.ResponseWriter, r *http.Request))

func (*Multiplexer) ServeHTTP

func (m *Multiplexer) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Multiplexer) SetErrorHandler

func (m *Multiplexer) SetErrorHandler(h func(w http.ResponseWriter, r *http.Request, code int))

type Node

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

func NewNode

func NewNode(parent *Node, tok Token) *Node

func (*Node) GetChildByRune

func (n *Node) GetChildByRune(char rune) *Node

func (*Node) GetChildByToken

func (n *Node) GetChildByToken(token Token) *Node

func (*Node) GetChildByTokenOrCreate

func (n *Node) GetChildByTokenOrCreate(token Token) *Node

func (*Node) GetLongest

func (n *Node) GetLongest(input string, setParam func(name, value string)) (*Node, bool)

func (*Node) SetValue

func (n *Node) SetValue(method Method, handler http.Handler) error

func (*Node) String

func (n *Node) String() string

type Token

type Token struct {
	Kind  TokenKind
	Lit   rune
	Param string
}

func (Token) String

func (tok Token) String() string

type TokenKind

type TokenKind uint8
const (
	Undefined TokenKind = iota
	Lit
	Sep
	Param
	End
)

func (TokenKind) String

func (kind TokenKind) String() string

Jump to

Keyboard shortcuts

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