44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
|
package framework
|
||
|
|
||
|
// IGroup prefix routes
|
||
|
type IGroup interface {
|
||
|
Get(string, ControllerHandler)
|
||
|
Post(string, ControllerHandler)
|
||
|
Put(string, ControllerHandler)
|
||
|
Delete(string, ControllerHandler)
|
||
|
}
|
||
|
|
||
|
// Group is the implementation of IGroup interface
|
||
|
type Group struct {
|
||
|
core *Core
|
||
|
prefix string
|
||
|
}
|
||
|
|
||
|
// NewGroup create a new prefix group
|
||
|
func NewGroup(core *Core, prefix string) *Group {
|
||
|
return &Group{
|
||
|
core: core,
|
||
|
prefix: prefix,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Get is a simple get router of the group
|
||
|
func (g *Group) Get(url string, handler ControllerHandler) {
|
||
|
g.core.Get(g.prefix+url, handler)
|
||
|
}
|
||
|
|
||
|
// Post is a simple post router of the group
|
||
|
func (g *Group) Post(url string, handler ControllerHandler) {
|
||
|
g.core.Post(g.prefix+url, handler)
|
||
|
}
|
||
|
|
||
|
// Put is a simple put router of the group
|
||
|
func (g *Group) Put(url string, handler ControllerHandler) {
|
||
|
g.core.Put(g.prefix+url, handler)
|
||
|
}
|
||
|
|
||
|
// Delete is a simple delete router of the group
|
||
|
func (g *Group) Delete(url string, handler ControllerHandler) {
|
||
|
g.core.Delete(g.prefix+url, handler)
|
||
|
}
|