framework1/framework/IGroup.go

40 lines
842 B
Go
Raw Normal View History

2024-10-16 16:53:09 +08:00
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) }