query

package
v0.7.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 7 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 NewQueryWithConfig

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

Types

type Config

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

type Contains

type Contains struct {
	Key   string
	Value string
}

func (*Contains) Match

func (s *Contains) Match(v url.Values) bool

type Exact

type Exact struct {
	Key   string
	Value string
}

func (*Exact) Match

func (e *Exact) Match(v url.Values) bool

type Matcher

type Matcher interface {
	Match(v url.Values) bool
}

type Prefix

type Prefix struct {
	Key   string
	Value string
}

func (*Prefix) Match

func (p *Prefix) Match(v url.Values) bool

type Present

type Present struct {
	Key string
}

func (*Present) Match

func (p *Present) Match(v url.Values) bool

type Query

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

Query is an host multiplexer.

func NewQuery

func NewQuery() *Query

NewQuery create a new Query.

func (*Query) Handle

func (q *Query) Handle(matches []Matcher, handler http.Handler)

func (*Query) Handler

func (q *Query) Handler(v url.Values) http.Handler

func (*Query) NotFound

func (q *Query) NotFound(handler http.Handler)

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

func (*Query) ServeHTTP

func (q *Query) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type Regexp

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

func (*Regexp) Match

func (r *Regexp) Match(v url.Values) bool

type Route

type Route struct {
	Matches []RouteMatch
	Handler http.Handler
}

type RouteMatch

type RouteMatch struct {
	Key      string
	Exact    string `json:",omitempty"`
	Present  bool   `json:",omitempty"`
	Regexp   string `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 url.Values) bool

Jump to

Keyboard shortcuts

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