1
0
Fork 0
forked from goffee/core

migration

This commit is contained in:
Zeni Kim 2024-09-15 19:19:54 -05:00
parent ac8ba89865
commit c6006861cb
6 changed files with 100 additions and 100 deletions

40
hooks.go Normal file
View file

@ -0,0 +1,40 @@
// Copyright 2021 Harran Ali <harran.m@gmail.com>. All rights reserved.
// 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
}