41 lines
733 B
Go
41 lines
733 B
Go
package ekko
|
|
|
|
import (
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type Ekko struct {
|
|
name string
|
|
prom prometheus.Registerer
|
|
port int
|
|
routeFn func(e *echo.Echo) error
|
|
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 WithOtelMiddleware(mw echo.MiddlewareFunc) func(*Ekko) {
|
|
return func(ek *Ekko) {
|
|
ek.otelmiddleware = mw
|
|
}
|
|
}
|