代码拉取完成,页面将自动刷新
package partner
import "github.com/gin-gonic/gin"
type CommonModel struct {
name string
allGetHandlers map[string][]gin.HandlerFunc
allPostHandlers map[string][]gin.HandlerFunc
}
var _ Model = (*CommonModel)(nil)
func NewCommonModel(name string) *CommonModel {
return &CommonModel{
name: name,
allGetHandlers: make(map[string][]gin.HandlerFunc),
allPostHandlers: make(map[string][]gin.HandlerFunc),
}
}
func (m *CommonModel) Name() string {
return m.name
}
func (m *CommonModel) GetHandlers() map[string][]gin.HandlerFunc {
return m.allGetHandlers
}
func (m *CommonModel) PostHandlers() map[string][]gin.HandlerFunc {
return m.allPostHandlers
}
func (m *CommonModel) SetGetHandlers(action string, handles ...gin.HandlerFunc) {
m.allGetHandlers[action] = handles
}
func (m *CommonModel) UseGetMiddlewares(action string, handles ...gin.HandlerFunc) {
m.allGetHandlers[action] = append(m.allGetHandlers[action], handles...)
l := len(handles)
copy(m.allGetHandlers[action][l:], m.allGetHandlers[action])
for i := 0; i < l; i++ {
m.allGetHandlers[action][i] = handles[i]
}
}
func (m *CommonModel) ClearGetHandlers(action string) {
delete(m.allGetHandlers, action)
}
func (m *CommonModel) SetPostHandlers(action string, handles ...gin.HandlerFunc) {
m.allPostHandlers[action] = handles
}
func (m *CommonModel) UsePostMiddlewares(action string, handles ...gin.HandlerFunc) {
m.allPostHandlers[action] = append(m.allPostHandlers[action], handles...)
l := len(handles)
copy(m.allPostHandlers[action][l:], m.allPostHandlers[action])
for i := 0; i < l; i++ {
m.allPostHandlers[action][i] = handles[i]
}
}
func (m *CommonModel) ClearPostHandlers(action string) {
delete(m.allPostHandlers, action)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。