outpost: separate ak-api and proxy further for future outposts

This commit is contained in:
Jens Langhammer
2021-01-16 21:41:39 +01:00
parent 87b830ff9a
commit 8fef839965
19 changed files with 392 additions and 318 deletions

20
outpost/pkg/ak/api_uag.go Normal file
View File

@ -0,0 +1,20 @@
package ak
import "net/http"
func SetUserAgent(inner http.RoundTripper, userAgent string) http.RoundTripper {
return &addUGA{
inner: inner,
Agent: userAgent,
}
}
type addUGA struct {
inner http.RoundTripper
Agent string
}
func (ug *addUGA) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Set("User-Agent", ug.Agent)
return ug.inner.RoundTrip(r)
}