common/ekko/options.go

49 lines
913 B
Go

package ekko
import (
"github.com/labstack/echo/v4"
"github.com/prometheus/client_golang/prometheus"
slogecho "github.com/samber/slog-echo"
)
type Ekko struct {
name string
prom prometheus.Registerer
port int
routeFn func(e *echo.Echo) error
logFilters []slogecho.Filter
otelmiddleware echo.MiddlewareFunc
}
type RouteFn func(e *echo.Echo) error
func WithPort(port int) func(*Ekko) {
return func(ek *Ekko) {
ek.port = port
}
}
func WithPrometheus(reg prometheus.Registerer) func(*Ekko) {
return func(ek *Ekko) {
ek.prom = reg
}
}
func WithEchoSetup(rfn RouteFn) func(*Ekko) {
return func(ek *Ekko) {
ek.routeFn = rfn
}
}
func WithLogFilters(f []slogecho.Filter) func(*Ekko) {
return func(ek *Ekko) {
ek.logFilters = f
}
}
func WithOtelMiddleware(mw echo.MiddlewareFunc) func(*Ekko) {
return func(ek *Ekko) {
ek.otelmiddleware = mw
}
}