hosts

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotHandler = fmt.Errorf("error not handler")
	ErrNotDomain  = fmt.Errorf("error not router")
)
View Source
var (
	ErrFormat = fmt.Errorf("error only a single asterisk is currently supported")
)

Functions

func NewHostsWithConfig

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

Types

type Config

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

type Hosts

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

Hosts is an hosts multiplexer.

func NewHosts

func NewHosts() *Hosts

func (*Hosts) Handle

func (h *Hosts) Handle(host string, handler http.Handler) error

func (*Hosts) Handler

func (h *Hosts) Handler(host string) (handler http.Handler)

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

func (*Hosts) NotFound

func (h *Hosts) NotFound(handler http.Handler)

func (*Hosts) ServeHTTP

func (h *Hosts) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Route

type Route struct {
	Domains []string
	Handler http.Handler
}

Jump to

Keyboard shortcuts

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