Documentation ¶
Index ¶
- func Vars(w server.ResponseWriter) map[string]string
- type Matcher
- type Route
- func (self *Route) Handle(handler server.Handler) *Route
- func (self *Route) HandleFunc(handler server.HandlerFunc) *Route
- func (self *Route) Match(w server.ResponseWriter, r *server.Request) server.ResponseWriter
- func (self *Route) Matcher(m Matcher) *Route
- func (self *Route) Path(path string) *Route
- func (self *Route) Prefix(path string) *Route
- func (self *Route) ServeGemini(w server.ResponseWriter, r *server.Request)
- type Router
- func (self *Router) HandlePath(path string, handler server.Handler)
- func (self *Router) HandlePathFunc(path string, handler server.HandlerFunc)
- func (self *Router) HandlePrefix(path string, handler server.Handler)
- func (self *Router) HandlePrefixFunc(path string, handler server.HandlerFunc)
- func (self *Router) Handler() *Route
- func (self *Router) ServeGemini(w server.ResponseWriter, r *server.Request)
- type VariablesResponseWriter
- func (self *VariablesResponseWriter) Flush() error
- func (self *VariablesResponseWriter) Header() *server.Header
- func (self *VariablesResponseWriter) PutVars(vars map[string]string) *VariablesResponseWriter
- func (self *VariablesResponseWriter) Unwrap() any
- func (self *VariablesResponseWriter) Write(data []byte) (int, error)
- func (self *VariablesResponseWriter) WriteHeader(status gmitools.StatusCode) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Matcher ¶
type Matcher interface { // Match a request. // // Return nil if the request does not match. // Return a ResponseWriter if the path does match. // // The returned ResponseWriter should be created from `w`. Some matchers will // inject variables into the ResponseWriter while others will make no // alterations. Match(w server.ResponseWriter, r *server.Request) server.ResponseWriter }
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
A route for a Router
This route matches against `Path()`. If the r.Path matches, then the given handler from `Handle()` or `HandleFunc()` will be served.
func (*Route) HandleFunc ¶
func (self *Route) HandleFunc(handler server.HandlerFunc) *Route
Set the handler for this route
func (*Route) Match ¶
func (self *Route) Match(w server.ResponseWriter, r *server.Request) server.ResponseWriter
func (*Route) Path ¶
Assign a path to the route.
This will match against the `r.Path`. The path must match exactly and there may be variables in the path.
Variables are designated by "{NAME}", "{NAME:TYPE}", or "{NAME~REGEX}". There are 4 types available:
* segment (default) `[^/]+`
* int `0|-?[1-9]\d*`
* path `.*`
* slug `[a-zA-Z0-9-]+`
The matched variables will be stored in the response writer and can be accessed by calling `router.Vars(w)`.
func (*Route) ServeGemini ¶
func (self *Route) ServeGemini(w server.ResponseWriter, r *server.Request)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) HandlePath ¶
Assign a path to the route.
This will match against the `r.Path`. The path must match exactly and there may be variables in the path.
Variables are designated by "{NAME}", "{NAME:TYPE}", or "{NAME~REGEX}". There are 4 types available:
* segment (default) `[^/]+`
* int `0|-?[1-9]\d*`
* path `.*`
* slug `[a-zA-Z0-9-]+`
The matched variables will be stored in the response writer and can be accessed by calling `router.Vars(w)`.
func (*Router) HandlePathFunc ¶
func (self *Router) HandlePathFunc(path string, handler server.HandlerFunc)
Assign a path to the route.
This will match against the `r.Path`. The path must match exactly and there may be variables in the path.
Variables are designated by "{NAME}", "{NAME:TYPE}", or "{NAME~REGEX}". There are 4 types available:
* segment (default) `[^/]+`
* int `0|-?[1-9]\d*`
* path `.*`
* slug `[a-zA-Z0-9-]+`
The matched variables will be stored in the response writer and can be accessed by calling `router.Vars(w)`.
func (*Router) HandlePrefix ¶
Match against a prefix
the route matches if `r.Path` begins with `path`
func (*Router) HandlePrefixFunc ¶
func (self *Router) HandlePrefixFunc(path string, handler server.HandlerFunc)
Match against a prefix
the route matches if `r.Path` begins with `path`
func (*Router) ServeGemini ¶
func (self *Router) ServeGemini(w server.ResponseWriter, r *server.Request)
type VariablesResponseWriter ¶
type VariablesResponseWriter struct { server.ResponseWriter Vars map[string]string }
func NewVariablesResponseWriter ¶
func NewVariablesResponseWriter(w server.ResponseWriter) *VariablesResponseWriter
Create a new VariablesResponseWriter from a given ResponseWriter
func (*VariablesResponseWriter) Flush ¶
func (self *VariablesResponseWriter) Flush() error
func (*VariablesResponseWriter) Header ¶
func (self *VariablesResponseWriter) Header() *server.Header
func (*VariablesResponseWriter) PutVars ¶
func (self *VariablesResponseWriter) PutVars(vars map[string]string) *VariablesResponseWriter
Put variables into the ResponseWriter
func (*VariablesResponseWriter) Unwrap ¶
func (self *VariablesResponseWriter) Unwrap() any
func (*VariablesResponseWriter) Write ¶
func (self *VariablesResponseWriter) Write(data []byte) (int, error)
func (*VariablesResponseWriter) WriteHeader ¶
func (self *VariablesResponseWriter) WriteHeader(status gmitools.StatusCode) error