header

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: MIT Imports: 6 Imported by: ? 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")
)

Functions

func NewHeaderWithConfig

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

Types

type Config

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

type Contains

type Contains struct {
	Key   string
	Value string
}

func (*Contains) Match

func (s *Contains) Match(v http.Header) bool

type Exact

type Exact struct {
	Key   string
	Value string
}

func (*Exact) Match

func (e *Exact) Match(v http.Header) bool
type Header struct {
	// contains filtered or unexported fields
}

Header is an host multiplexer.

func NewHeader

func NewHeader() *Header

NewHeader create a new Header.

func (*Header) Handle

func (h *Header) Handle(matches []Matcher, handler http.Handler)

func (*Header) Handler

func (h *Header) Handler(v http.Header) http.Handler

func (*Header) NotFound

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

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

func (*Header) ServeHTTP

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

type MatchRange

type MatchRange struct {
	Start int64
	End   int64
}

type Matcher

type Matcher interface {
	Match(v http.Header) bool
}

type Prefix

type Prefix struct {
	Key   string
	Value string
}

func (*Prefix) Match

func (p *Prefix) Match(v http.Header) bool

type Present

type Present struct {
	Key string
}

func (*Present) Match

func (p *Present) Match(v http.Header) bool

type Range

type Range struct {
	Key   string
	Start int64
	End   int64
}

func (*Range) Match

func (r *Range) Match(v http.Header) bool

type Regexp

type Regexp struct {
	Key   string
	Value *regexp.Regexp
}

func (*Regexp) Match

func (r *Regexp) Match(v http.Header) bool

type Route

type Route struct {
	Key     string
	Headers []RouteMatch
	Handler http.Handler
}

type RouteMatch

type RouteMatch struct {
	Exact    string      `json:",omitempty"`
	Present  bool        `json:",omitempty"`
	Regexp   string      `json:",omitempty"`
	Range    *MatchRange `json:",omitempty"`
	Prefix   string      `json:",omitempty"`
	Suffix   string      `json:",omitempty"`
	Contains string      `json:",omitempty"`
}

type Suffix

type Suffix struct {
	Key   string
	Value string
}

func (*Suffix) Match

func (s *Suffix) Match(v http.Header) bool

Jump to

Keyboard shortcuts

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