2015-05-23 05:26:52 +02:00
|
|
|
package echo
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Group is a set of subroutes for a specified route. It can be used for inner
|
|
|
|
// routes that share a common middlware or functionality that should be separate
|
|
|
|
// from the parent echo instance while still inheriting from it.
|
|
|
|
type Group struct {
|
|
|
|
echo Echo
|
|
|
|
}
|
2015-05-23 06:24:35 +02:00
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Use implements the echo.Use interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Use(m ...Middleware) {
|
|
|
|
for _, h := range m {
|
|
|
|
g.echo.middleware = append(g.echo.middleware, wrapMiddleware(h))
|
|
|
|
}
|
2016-11-03 19:41:43 +02:00
|
|
|
|
|
|
|
g.echo.Any(g.echo.prefix+"*", notFoundHandler)
|
2015-05-23 06:24:35 +02:00
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Connect implements the echo.Connect interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Connect(path string, h Handler) {
|
|
|
|
g.echo.Connect(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Delete implements the echo.Delete interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Delete(path string, h Handler) {
|
|
|
|
g.echo.Delete(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Get implements the echo.Get interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Get(path string, h Handler) {
|
|
|
|
g.echo.Get(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Head implements the echo.Head interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Head(path string, h Handler) {
|
|
|
|
g.echo.Head(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Options implements the echo.Options interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Options(path string, h Handler) {
|
|
|
|
g.echo.Options(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Patch implements the echo.Patch interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Patch(path string, h Handler) {
|
|
|
|
g.echo.Patch(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Post implements the echo.Post interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Post(path string, h Handler) {
|
|
|
|
g.echo.Post(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Put implements the echo.Put interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Put(path string, h Handler) {
|
|
|
|
g.echo.Put(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Trace implements the echo.Trace interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Trace(path string, h Handler) {
|
|
|
|
g.echo.Trace(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Any implements the echo.Any interface for subroutes within the Group.
|
2016-01-09 20:34:34 +02:00
|
|
|
func (g *Group) Any(path string, h Handler) {
|
|
|
|
for _, m := range methods {
|
|
|
|
g.echo.add(m, path, h)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Match implements the echo.Match interface for subroutes within the Group.
|
2016-01-09 20:34:34 +02:00
|
|
|
func (g *Group) Match(methods []string, path string, h Handler) {
|
|
|
|
for _, m := range methods {
|
|
|
|
g.echo.add(m, path, h)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// WebSocket implements the echo.WebSocket interface for subroutes within the
|
|
|
|
// Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) WebSocket(path string, h HandlerFunc) {
|
|
|
|
g.echo.WebSocket(path, h)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Static implements the echo.Static interface for subroutes within the Group.
|
2015-05-27 23:07:52 +02:00
|
|
|
func (g *Group) Static(path, root string) {
|
|
|
|
g.echo.Static(path, root)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// ServeDir implements the echo.ServeDir interface for subroutes within the
|
|
|
|
// Group.
|
2015-05-27 23:07:52 +02:00
|
|
|
func (g *Group) ServeDir(path, root string) {
|
|
|
|
g.echo.ServeDir(path, root)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// ServeFile implements the echo.ServeFile interface for subroutes within the
|
|
|
|
// Group.
|
2015-05-27 23:07:52 +02:00
|
|
|
func (g *Group) ServeFile(path, file string) {
|
|
|
|
g.echo.ServeFile(path, file)
|
|
|
|
}
|
|
|
|
|
2016-01-29 14:06:20 +02:00
|
|
|
// Group implements the echo.Group interface for subroutes within the Group.
|
2015-05-23 06:24:35 +02:00
|
|
|
func (g *Group) Group(prefix string, m ...Middleware) *Group {
|
|
|
|
return g.echo.Group(prefix, m...)
|
|
|
|
}
|