Documentation ¶
Overview ¶
Package segment provide segment based routing
segment based routing is considered low level, use path/segment based routing for high level routing.
Index ¶
- func EndOr(otherwise http.HandlerFunc) func(http.HandlerFunc) http.HandlerFunc
- func Get(r *http.Request, tag string) (string, bool)
- func Last(h http.HandlerFunc) http.HandlerFunc
- func MustEnd(h http.HandlerFunc) http.HandlerFunc
- func Param(r *http.Request, tag string) string
- func Rest(r *http.Request) []string
- func Split(r *http.Request) ([]string, []string)
- func Stripper(next http.HandlerFunc) http.HandlerFunc
- func Tag(tag string, next http.HandlerFunc) http.HandlerFunc
- type H
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EndOr ¶
func EndOr(otherwise http.HandlerFunc) func(http.HandlerFunc) http.HandlerFunc
EndOr return middleware that only will execute h when its position is last segment of the path if otherwise is nil, defhandler.StatusNotFound is used.
func Last ¶ added in v1.1.0
func Last(h http.HandlerFunc) http.HandlerFunc
Last is synonym for MustEnd
func MustEnd ¶
func MustEnd(h http.HandlerFunc) http.HandlerFunc
MustEnd same as EndOr with otherwise equal to nil.
func Stripper ¶
func Stripper(next http.HandlerFunc) http.HandlerFunc
Stripper is middleware for stripping processed segment from r.URL.Path
func Tag ¶
func Tag(tag string, next http.HandlerFunc) http.HandlerFunc
Tag return helper that will tag current segment and process to next segment
The tagged segment can be retrieved later via Get function.
Types ¶
type H ¶
type H map[string]http.HandlerFunc
H is type for mapping segment and its handler
func (H) Compile ¶
func (h H) Compile(def http.HandlerFunc) http.HandlerFunc
Compile into single http.HandlerFunc. if def is nil, default handler is defhandler.StatusNotFound