registry: Refactor requestfactory to use http.RoundTrippers
This patch removes the need for requestFactories and decorators by implementing http.RoundTripper transports instead. It refactors some challenging-to-read code. NewSession now takes an *http.Client that can already have a custom Transport, it will add its own auth transport by wrapping it. The idea is that callers of http.Client should not bother setting custom headers for every handler but instead it should be transparent to the callers of a same context. This patch is needed for future refactorings of registry, namely refactoring of the v1 client code. Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
parent
172a4e1f5a
commit
db107e3e2c
1 changed files with 2 additions and 2 deletions
|
@ -47,7 +47,7 @@ func (vi *UAVersionInfo) isValid() bool {
|
|||
// "product/version", where the "product" is get from the name field, while
|
||||
// version is get from the version field. Several pieces of verson information
|
||||
// will be concatinated and separated by space.
|
||||
func appendVersions(base string, versions ...UAVersionInfo) string {
|
||||
func AppendVersions(base string, versions ...UAVersionInfo) string {
|
||||
if len(versions) == 0 {
|
||||
return base
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ func (h *UserAgentDecorator) ChangeRequest(req *http.Request) (*http.Request, er
|
|||
return req, ErrNilRequest
|
||||
}
|
||||
|
||||
userAgent := appendVersions(req.UserAgent(), h.Versions...)
|
||||
userAgent := AppendVersions(req.UserAgent(), h.Versions...)
|
||||
if len(userAgent) > 0 {
|
||||
req.Header.Set("User-Agent", userAgent)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue