userAgent.go 544 B

123456789101112131415161718192021
  1. // Copyright 2020-2021 InfluxData, Inc. All rights reserved.
  2. // Use of this source code is governed by MIT
  3. // license that can be found in the LICENSE file.
  4. // Package http hold internal HTTP related stuff
  5. package http
  6. import (
  7. "fmt"
  8. )
  9. // UserAgentBase keeps once created base User-Agent string
  10. var UserAgentBase string
  11. // FormatUserAgent creates User-Agent header value for application name
  12. func FormatUserAgent(appName string) string {
  13. if appName != "" {
  14. return fmt.Sprintf("%s %s", UserAgentBase, appName)
  15. }
  16. return UserAgentBase
  17. }