ekko: helper to setup labstack echo with logging, tracing, etc
This commit is contained in:
40
ekko/options.go
Normal file
40
ekko/options.go
Normal file
@@ -0,0 +1,40 @@
|
||||
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
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user