40 lines
842 B
Go
40 lines
842 B
Go
|
package framework
|
||
|
|
||
|
type IGroup interface {
|
||
|
Get(string, ControllerHandler)
|
||
|
Post(string, ControllerHandler)
|
||
|
Put(string, ControllerHandler)
|
||
|
Delete(string, ControllerHandler)
|
||
|
}
|
||
|
|
||
|
type Group struct {
|
||
|
core *Core
|
||
|
prefix string
|
||
|
}
|
||
|
|
||
|
func NewGroup(core *Core, prefix string) *Group {
|
||
|
return &Group{core, prefix}
|
||
|
}
|
||
|
|
||
|
func (g *Group) Get(uri string, handler ControllerHandler) {
|
||
|
uri = g.prefix + uri
|
||
|
g.core.Get(uri, handler)
|
||
|
}
|
||
|
|
||
|
func (g *Group) Post(uri string, handler ControllerHandler) {
|
||
|
uri = g.prefix + uri
|
||
|
g.core.POST(uri, handler)
|
||
|
}
|
||
|
|
||
|
func (g *Group) Put(uri string, handler ControllerHandler) {
|
||
|
uri = g.prefix + uri
|
||
|
g.core.PUT(uri, handler)
|
||
|
}
|
||
|
|
||
|
func (g *Group) Delete(uri string, handler ControllerHandler) {
|
||
|
uri = g.prefix + uri
|
||
|
g.core.DELETE(uri, handler)
|
||
|
}
|
||
|
|
||
|
func (c *Core) Group(prefix string) IGroup { return NewGroup(c, prefix) }
|