Worker: set user agent string
This commit is contained in:
parent
082e2e69d6
commit
30c04f4ddb
@ -30,6 +30,10 @@ func main() {
|
|||||||
flamenco, err := api.NewClientWithResponses(
|
flamenco, err := api.NewClientWithResponses(
|
||||||
"http://localhost:8080/",
|
"http://localhost:8080/",
|
||||||
api.WithRequestEditorFn(basicAuthProvider.Intercept),
|
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 {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("error creating client")
|
log.Fatal().Err(err).Msg("error creating client")
|
||||||
|
@ -12,3 +12,8 @@ var ApplicationVersion = "set-during-build"
|
|||||||
func FormattedApplicationInfo() string {
|
func FormattedApplicationInfo() string {
|
||||||
return fmt.Sprintf("%s %s", ApplicationName, ApplicationVersion)
|
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)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user