1
0
Fork 0
forked from goffee/core
core/hooks.go
2024-09-16 16:01:44 -05:00

39 lines
581 B
Go

// 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
}