1
0
Fork 0
forked from goffee/core
core/hooks.go

40 lines
581 B
Go
Raw Normal View History

2024-09-15 20:19:54 -04:00
// Copyright (c) 2024 Zeni Kim <zenik@smarteching.com>
// Use of this source code is governed by MIT-style
// license that can be found in the LICENSE file.
package core
type Hooks struct {
hooks []Hook
}
var m *Hooks
func NewHooks() *Hooks {
m = &Hooks{}
return m
}
func ResolveHooks() *Hooks {
return m
}
func (m *Hooks) Attach(mw Hook) *Hooks {
m.hooks = append(m.hooks, mw)
return m
}
func (m *Hooks) GetHooks() []Hook {
return m.hooks
}
func (m *Hooks) getByIndex(i int) Hook {
for k := range m.hooks {
if k == i {
return m.hooks[i]
}
}
return nil
}