router

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Route

type Route interface {
	// ID returns the int32 message ID this route handles.
	ID() int

	// Name returns the name of the route, useful for logging.
	Name() string

	// Handler returns the bmux.HandlerFunc for this message.
	Handler() handler.HandlerFunc

	// Status indicates whether the route is enabled.
	Status() bool

	// Experimental indicates if the route is experimental.
	Experimental() bool

	// Middleware returns middleware applied only to this route.
	Middleware() []func(handler.HandlerFunc) handler.HandlerFunc
}

Route defines a handler for a specific message ID in the bmux protocol.

func NewRoute

func NewRoute(
	name string,
	id int,
	status, experimental bool,
	handler handler.HandlerFunc,
	middleware []func(handler.HandlerFunc) handler.HandlerFunc,
	opts ...RouteWrapper,
) Route

type RouteWrapper

type RouteWrapper func(r Route) Route

type Router

type Router interface {
	// Routes returns all registered routes in the router.
	Routes() []Route

	// Status indicates whether this router is currently active.
	Status() bool

	// Middleware returns router-level middleware applied to all routes.
	// Middleware wraps the handler with additional behavior.
	Middleware() []func(handler.HandlerFunc) handler.HandlerFunc
}

Router defines a message-based router for the bmux protocol. It maps incoming message identifiers (int32) to handlers, supports middleware, and allows for enabling/disabling routers.

func NewRouter

func NewRouter(
	status bool,
	routes []Route,
	middleware []func(handler.HandlerFunc) handler.HandlerFunc,
	opts ...RouterWrapper,
) Router

type RouterWrapper

type RouterWrapper func(r Router) Router

Jump to

Keyboard shortcuts

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