From 92b202037a1b9ec6cc48bbc81cdfa0c7ecc923b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ask=20Bj=C3=B8rn=20Hansen?= Date: Sun, 8 Mar 2026 17:41:41 -0700 Subject: [PATCH] fix(ekko): store service name and add fallback for Server header The name parameter passed to ekko.New() was never stored on the struct, causing the HTTP Server header to be malformed (e.g. "/vdev-snapshot+hash" instead of "warmform/vdev-snapshot+hash"). Store the name in the struct literal and add a fallback that derives the name from debug.ReadBuildInfo() if an empty string is passed. --- ekko/ekko.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ekko/ekko.go b/ekko/ekko.go index b067efe..623a0b8 100644 --- a/ekko/ekko.go +++ b/ekko/ekko.go @@ -34,6 +34,8 @@ import ( "fmt" "net" "net/http" + "runtime/debug" + "strings" "time" "github.com/labstack/echo-contrib/echoprometheus" @@ -70,6 +72,7 @@ import ( // - WithGzipConfig(): Custom gzip compression settings func New(name string, options ...func(*Ekko)) (*Ekko, error) { ek := &Ekko{ + name: name, writeTimeout: 60 * time.Second, readHeaderTimeout: 30 * time.Second, } @@ -77,6 +80,20 @@ func New(name string, options ...func(*Ekko)) (*Ekko, error) { for _, o := range options { o(ek) } + + if ek.name == "" { + if bi, ok := debug.ReadBuildInfo(); ok && bi.Main.Path != "" { + if idx := strings.LastIndex(bi.Main.Path, "/"); idx >= 0 { + ek.name = bi.Main.Path[idx+1:] + } else { + ek.name = bi.Main.Path + } + } + if ek.name == "" { + ek.name = "ekko-app" + } + } + return ek, nil }