Documentation ¶
Overview ¶
Package route provides slim representation of routes that is used by go-on/router.Router and may be used by client side libraries such as gopherjs.
A route intentionally has no handler. That is left to be defined/assigned by the server side library - that is go-on/router. Therefor some properties of Route that must not be changed by hand are exported to allow go-on/router to do its work.
Index ¶
- Variables
- func Mount(mountPoint string, routes ...*Route)
- func Options(r *Route) []string
- type ErrDoubleMounted
- type ErrMissingParam
- type ErrPairParams
- type ErrRouteIsNil
- type ErrUnknownMethod
- type Route
- func (r *Route) HasMethod(m method.Method) (has bool)
- func (r *Route) HasParams() bool
- func (r *Route) MountedPath() string
- func (r *Route) MustURL(params ...string) string
- func (r *Route) MustURLMap(params map[string]string) string
- func (r *Route) URL(params ...string) (string, error)
- func (r *Route) URLMap(params map[string]string) (string, error)
Constants ¶
This section is empty.
Variables ¶
var PARAM_PREFIX = []byte(":")[0]
Functions ¶
Types ¶
type ErrDoubleMounted ¶
ErrDoubleMounted is raised if the route already has been mounted.
func (*ErrDoubleMounted) Error ¶
func (e *ErrDoubleMounted) Error() string
type ErrMissingParam ¶
ErrMissingParam is raised if a route URL parameter is missing.
func (ErrMissingParam) Error ¶
func (e ErrMissingParam) Error() string
type ErrPairParams ¶
type ErrPairParams struct{}
ErrPairParams is raised if a variadic parameter group has no pairs.
func (ErrPairParams) Error ¶
func (ErrPairParams) Error() string
type ErrRouteIsNil ¶
type ErrRouteIsNil struct{}
ErrRouteIsNil is raised if a route is not yet defined.
func (ErrRouteIsNil) Error ¶
func (e ErrRouteIsNil) Error() string
type ErrUnknownMethod ¶
type ErrUnknownMethod struct {
method.Method
}
ErrUnknownMethod is raised if the given http method is not known.
func (ErrUnknownMethod) Error ¶
func (e ErrUnknownMethod) Error() string
type Route ¶
type Route struct { // Id will be set by the go-on/router.Router, don't touch it! // An internal attribute but exported because it is cross-package Id string // Methods will be read by the go-on/router.Router, don't touch it! // An internal attribute but exported because it is cross-package Methods map[method.Method]struct{} // DefinitionPath will be read by the go-on/router.Router, don't touch it! // An internal attribute but exported because it is cross-package DefinitionPath string // Router will be set by either Mount or go-on/router.Router, don't touch it! // An internal attribute but exported because it is cross-package Router interface { // MountPath returns the path where the router is mounted MountPath() string } }
Don't directly change the properties of Route. Instead use only the methods. These properties only are exported to be used by Router
func New ¶
New creates a new route for the given path and methods. The methods for the route must not be changed after the call of New
func (*Route) MountedPath ¶
MountedPath returns the path of the mounted route
func (*Route) MustURLMap ¶
MustURLMap is like URLMap but panics on errors