path

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: MIT Imports: 9 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 NewPathWithConfig

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

Types

type Config

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

type Path

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

Path is an host multiplexer.

func NewPath

func NewPath() *Path

NewPath create a new Path.

func (*Path) HandlePath

func (p *Path) HandlePath(path string, handler http.Handler)

func (*Path) HandlePrefix

func (p *Path) HandlePrefix(prefix string, handler http.Handler) error

func (*Path) HandlePrefixAndRegexp

func (p *Path) HandlePrefixAndRegexp(prefix, reg string, handler http.Handler) error

func (*Path) Handler

func (p *Path) Handler(path string) (handler http.Handler)

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

func (*Path) NotFound

func (p *Path) NotFound(handler http.Handler)

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

func (*Path) ServeHTTP

func (p *Path) 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