This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2022-06-20 09:54:10 +00:00
|
|
|
package web
|
2021-09-08 18:04:56 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type userAgentTransport struct {
|
|
|
|
inner http.RoundTripper
|
|
|
|
ua string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewUserAgentTransport(ua string, inner http.RoundTripper) *userAgentTransport {
|
|
|
|
return &userAgentTransport{inner, ua}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (uat *userAgentTransport) RoundTrip(r *http.Request) (*http.Response, error) {
|
|
|
|
r.Header.Set("User-Agent", uat.ua)
|
|
|
|
return uat.inner.RoundTrip(r)
|
|
|
|
}
|