Worker: set user agent string

This commit is contained in:
Sybren A. Stüvel 2022-01-07 14:37:04 +01:00 committed by Sybren A. Stüvel
parent 082e2e69d6
commit 30c04f4ddb
2 changed files with 9 additions and 0 deletions

@ -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")

@ -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)
}