Documentation ¶
Overview ¶
Package trie implements a variant of http.ServeMux that uses a trie instead of a map.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Domain ¶
type Domain struct {
Trie
}
Domain serves the trie for a specific domain.
Domains are the handlers registered for each domain within a ServeMux.
type ServeMux ¶
type ServeMux struct {
Trie
}
ServeMux serves the tries for all configured domains.
func NewServeMux ¶
func NewServeMux() *ServeMux
NewServeMux creates a new ServeMux with no handlers registered.
func (*ServeMux) Handle ¶
Handle registers the given handler to be called on requests matching the given pattern. In general, the pattern takes the following form:
<domain>/<path>
Both the domain and the path portions are optional.
func (*ServeMux) HandleFunc ¶
HandleFunc is like Handle, but it takes a function compatible with http.HandlerFunc.
type Trie ¶
type Trie struct { Name string // path piece Child []*Trie // child tries Leaf http.Handler // handler for this file/dir or nil to use parent }
A Trie can store a prefix tree of paths or a suffix tree of domains. It is the basis for the Domain and ServeMux type.
func (*Trie) Find ¶
Find attempts to find the deepest matching child of this Trie with a non-nil Leaf and return the number of path segments required to reach it and the Trie present at that location.