mirror of
https://github.com/hanzo-fi/go-libs.git
synced 2026-10-30 20:53:44 +00:00
32 lines
596 B
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
|
|
}
|