diff --git a/cmd/flamenco-worker-poc/main.go b/cmd/flamenco-worker-poc/main.go index 853a8ae1..90f956f0 100644 --- a/cmd/flamenco-worker-poc/main.go +++ b/cmd/flamenco-worker-poc/main.go @@ -30,6 +30,10 @@ func main() { flamenco, err := api.NewClientWithResponses( "http://localhost:8080/", api.WithRequestEditorFn(basicAuthProvider.Intercept), + api.WithRequestEditorFn(func(ctx context.Context, req *http.Request) error { + req.Header.Set("User-Agent", appinfo.UserAgent()) + return nil + }), ) if err != nil { log.Fatal().Err(err).Msg("error creating client") diff --git a/internal/appinfo/appinfo.go b/internal/appinfo/appinfo.go index 0138f297..a769c19e 100644 --- a/internal/appinfo/appinfo.go +++ b/internal/appinfo/appinfo.go @@ -12,3 +12,8 @@ var ApplicationVersion = "set-during-build" func FormattedApplicationInfo() string { return fmt.Sprintf("%s %s", ApplicationName, ApplicationVersion) } + +// UserAgent returns the application name & version suitable for the HTTP User-Agent header. +func UserAgent() string { + return fmt.Sprintf("%s/%s", ApplicationName, ApplicationVersion) +}