core/middlewares.go

41 lines
785 B
Go
Raw Normal View History

2024-09-12 18:13:16 -04:00
// 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 Middlewares struct {
middlewares []Middleware
}
var m *Middlewares
func NewMiddlewares() *Middlewares {
m = &Middlewares{}
return m
}
func ResolveMiddlewares() *Middlewares {
return m
}
func (m *Middlewares) Attach(mw Middleware) *Middlewares {
m.middlewares = append(m.middlewares, mw)
return m
}
func (m *Middlewares) GetMiddlewares() []Middleware {
return m.middlewares
}
func (m *Middlewares) getByIndex(i int) Middleware {
for k := range m.middlewares {
if k == i {
return m.middlewares[i]
}
}
return nil
}