Documentation
¶
Index ¶
- func EqualLocation(a, b Location) bool
- type AnyModelAdapter
- type Encoder
- type HookMatch
- type Location
- type Match
- type ModelAdapter
- type PathMaker
- func (pm PathMaker) Hook(instanceId string, hookId uint64, name string) string
- func (pm PathMaker) ID() string
- func (pm PathMaker) IsSystem(r *http.Request) bool
- func (pm PathMaker) Match(r *http.Request) (Match, bool)
- func (pm PathMaker) Prefix() string
- func (pm PathMaker) Resource(r *resources.Resource, name string) string
- func (pm PathMaker) ServerIDCookieName() string
- func (pm PathMaker) SessionCookie() string
- func (pm PathMaker) SetServerIDCookie() bool
- type UndoPath
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EqualLocation ¶
EqualLocation reports whether a and b encode the same path and query.
Types ¶
type AnyModelAdapter ¶ added in v0.12.1
type Encoder ¶ added in v0.12.1
type Encoder interface {
// Encode returns the location the model points to.
Encode() (Location, error)
}
Encoder is implemented by models that build their own Location instead of describing their path with tags.
type Location ¶
type Location struct {
// Segments are the path segments, decoded and without the separating
// slashes. Empty means the root path.
Segments []string `json:"segments"`
// Query holds the query parameters in decoded form. Empty means no query
// string.
Query url.Values `json:"query"`
}
Location is a URL path plus query string, held in decoded form.
func Encode ¶ added in v0.12.1
Encode returns the Location for m.
m may be a Location, a value implementing Encoder, a path model struct, or a pointer to one. It returns an error if m is none of these, if its path tags are invalid, or if it does not encode to a complete path.
func NewLocationFromEscapedURI ¶
NewLocationFromEscapedURI parses s into a Location. If s is not a valid URL reference, it returns the zero Location.
func NewLocationFromURL ¶
NewLocationFromURL decodes u into a Location.
func (Location) Clone ¶ added in v0.12.10
Clone returns a deep copy of l with independent Segments and Query.
func (Location) MarshalJSON ¶ added in v0.15.0
MarshalJSON encodes nil Segments and Query as empty containers instead of null.
type ModelAdapter ¶ added in v0.12.1
type ModelAdapter[M any] adapter
ModelAdapter decodes locations into path model M and encodes M back.
func GetModelAdapter ¶ added in v0.12.1
func GetModelAdapter[M any]() (ModelAdapter[M], error)
GetModelAdapter returns the ModelAdapter for path model M. It returns an error if M is not a struct or its path tags are missing or invalid.
func (ModelAdapter[M]) Decode ¶ added in v0.12.1
func (ma ModelAdapter[M]) Decode(l Location) (*M, bool)
Decode returns the model decoded from l, and false if l matches no path variant of M.
func (ModelAdapter[M]) Encode ¶ added in v0.12.1
func (ma ModelAdapter[M]) Encode(m *M) (Location, error)
Encode returns the location for m, or an error if m selects no path variant or leaves a path capture empty.
type PathMaker ¶
type PathMaker struct {
// contains filtered or unexported fields
}