mux

package
v0.4.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotHandler = fmt.Errorf("error not handler")
	ErrNotRouter  = fmt.Errorf("error not router")
)
View Source
var (
	ErrRouteAlreadyExists = fmt.Errorf("error route already exists")
)

Functions

func NewMuxWithConfig

func NewMuxWithConfig(conf *Config) (http.Handler, error)

Types

type Config

type Config struct {
	Routes   []*Route
	NotFound http.Handler `json:",omitempty"`
}

type Mux

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

Mux is an Applicative protocol multiplexer.

func NewMux

func NewMux() *Mux

NewMux create a new Mux.

func (*Mux) HandlePath

func (m *Mux) HandlePath(path string, handler http.Handler)

func (*Mux) HandlePrefix

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

func (*Mux) HandlePrefixAndRegexp

func (m *Mux) HandlePrefixAndRegexp(prefix, reg string, handler http.Handler) error

func (*Mux) Handler

func (m *Mux) Handler(path string) (handler http.Handler)

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

func (*Mux) NotFound

func (m *Mux) NotFound(handler http.Handler)

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

func (*Mux) ServeHTTP

func (m *Mux) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Route

type Route struct {
	Prefix  string `json:",omitempty"`
	Path    string `json:",omitempty"`
	Regexp  string `json:",omitempty"`
	Handler http.Handler
}

Jump to

Keyboard shortcuts

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