mirror of
https://github.com/documize/community.git
synced 2025-07-19 21:29:42 +02:00
Streamlined add router methods
This commit is contained in:
parent
80f0876b51
commit
bfe5262cb5
1 changed files with 8 additions and 7 deletions
|
@ -79,23 +79,24 @@ func routesKey(rt *env.Runtime, prefix, path string, methods, queries []string)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an endpoint to those that will be processed when Serve() is called.
|
// Add an endpoint to those that will be processed when Serve() is called.
|
||||||
func Add(rt *env.Runtime, prefix, path string, methods, queries []string, endPtFn RouteFunc) error {
|
func Add(rt *env.Runtime, prefix, path string, methods, queries []string, endPtFn RouteFunc) {
|
||||||
k, e := routesKey(rt, prefix, path, methods, queries)
|
k, e := routesKey(rt, prefix, path, methods, queries)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return e
|
rt.Log.Error("unable to add route", e)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
routes[k] = endPtFn
|
routes[k] = endPtFn
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddPrivate endpoint
|
// AddPrivate endpoint
|
||||||
func AddPrivate(rt *env.Runtime, path string, methods, queries []string, endPtFn RouteFunc) error {
|
func AddPrivate(rt *env.Runtime, path string, methods, queries []string, endPtFn RouteFunc) {
|
||||||
return Add(rt, RoutePrefixPrivate, path, methods, queries, endPtFn)
|
Add(rt, RoutePrefixPrivate, path, methods, queries, endPtFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddPublic endpoint
|
// AddPublic endpoint
|
||||||
func AddPublic(rt *env.Runtime, path string, methods, queries []string, endPtFn RouteFunc) error {
|
func AddPublic(rt *env.Runtime, path string, methods, queries []string, endPtFn RouteFunc) {
|
||||||
return Add(rt, RoutePrefixPublic, path, methods, queries, endPtFn)
|
Add(rt, RoutePrefixPublic, path, methods, queries, endPtFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove an endpoint.
|
// Remove an endpoint.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue