Files
go-libs/pkg/testing/testservice/instrumentation_httpserver.go

32 lines
596 B
Go

package testservice
import (
"context"
"net/url"
"github.com/hanzo-fi/go-libs/v5/pkg/transport/httpserver"
)
func HTTPServerInstrumentation() Instrumentation {
return InstrumentationFunc(func(ctx context.Context, cfg *RunConfiguration) error {
cfg.WrapContext(func(ctx context.Context) context.Context {
return httpserver.ContextWithServerInfo(ctx)
})
return nil
})
}
func GetServerURL(service *Service) *url.URL {
rawUrl := httpserver.URL(service.GetContext())
if rawUrl == "" {
return nil
}
url, err := url.Parse(rawUrl)
if err != nil {
panic(err)
}
return url
}