mux

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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