router

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeRouteMatcher added in v0.4.0

func MakeRouteMatcher(opts ...MakeRouteMatcherOptions) func(pattern, topic string) bool

MakeRouteMatcher creates a configurable pattern matching function The returned function has the signature func(pattern, topic string) bool. When used with the Mux, "pattern" is the registered route pattern (eg. "users.*.profile") and "topic" is the actual topic being matched (eg. "users.123.profile")

Types

type Entry

type Entry struct {
	Handler any
	// contains filtered or unexported fields
}

func (*Entry) Pattern added in v0.4.0

func (i *Entry) Pattern() string

func (*Entry) Unsubscribe

func (i *Entry) Unsubscribe()

type MakeRouteMatcherOptions added in v0.4.0

type MakeRouteMatcherOptions struct {
	Separator          string // separator for splitting pattern/topic (default: "/")
	OnlyFinalSegment   bool   // if true, multi-level wildcard (#) must be final segment (default: false)
	PatternTransformer func(string) string
}

MakeRouteMatcherOptions configures the route matching behavior

type Mux

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

func NewMux

func NewMux(opts ...Option) *Mux

func (*Mux) Add

func (m *Mux) Add(pattern string, handler any) *Entry

func (*Mux) Get

func (m *Mux) Get(etype string) []Entry

type Option

type Option func(m *Mux)

func WithEntryComparator

func WithEntryComparator(comp func(a, b any) bool) Option

func WithMatcher added in v0.4.0

func WithMatcher(matcher func(pattern, topic string) bool) Option

func WithRouteMatcher

func WithRouteMatcher(matcher func(t, p string) bool) Option

type Subscription

type Subscription interface {
	Unsubscribe()
}

Jump to

Keyboard shortcuts

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