mux

package
v0.0.2-rc5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAddress = errors.New("not address")
	ErrNotFound   = errors.New("not found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Patterns []*Pattern
	Routes   map[string]modules.Handlers
	NotFound string
}

type Mux

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

Mux is an Applicative protocol multiplexer It matches the prefix of each incoming reader against a list of registered patterns and calls the handler for the pattern that most closely matches the Handler.

func NewMux

func NewMux() *Mux

NewProtoMux create a new Mux.

func NewMuxWithConfig

func NewMuxWithConfig(conf *Config) (*Mux, error)

func (*Mux) Handle

func (m *Mux) Handle(pattern string, handler modules.Handler) error

Handle registers the handler for the given pattern in the Mux.

func (*Mux) Handler

func (m *Mux) Handler(r io.Reader) (handler modules.Handler, prefix []byte, err error)

Handler returns most matching handler and prefix bytes data to use for the given reader.

func (*Mux) NotFound

func (m *Mux) NotFound(handler modules.Handler) error

NotFound replies to the handler with an Handler not found error.

func (*Mux) Pattern

func (m *Mux) Pattern(name string, pattern string)

func (*Mux) ServeMux

func (m *Mux) ServeMux(ctx context.Context, conn net.Conn)

ServeMux dispatches the reader to the handler whose pattern most closely matches the reader.

type Pattern

type Pattern struct {
	Name    string
	Pattern string
}

Jump to

Keyboard shortcuts

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