shunt

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 8 Imported by: 0

README

shunt

A stream router

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = fmt.Errorf("error not found")
)

Functions

func Unread

func Unread(reader io.Reader, prefix []byte) io.Reader

func UnreadConn

func UnreadConn(conn net.Conn, prefix []byte) net.Conn

func UnwrapUnread

func UnwrapUnread(reader io.Reader) (io.Reader, []byte)

func UnwrapUnreadConn

func UnwrapUnreadConn(conn net.Conn) (net.Conn, []byte)

Types

type Handler

type Handler interface {
	ServeConn(conn net.Conn)
}

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 (*Mux) HandlePrefix

func (m *Mux) HandlePrefix(prefix string, handler Handler) error

func (*Mux) HandleRegexp

func (m *Mux) HandleRegexp(pattern string, handler Handler) error

func (*Mux) Handler

func (m *Mux) Handler(r io.Reader) (handler 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 Handler) error

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

func (*Mux) ServeConn

func (m *Mux) ServeConn(conn net.Conn)

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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