github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/pkg/proxy/transport/registry.go (about) 1 package transport 2 3 import ( 4 "net/http" 5 "sync" 6 ) 7 8 type registry struct { 9 sync.RWMutex 10 store map[string]*http.Transport 11 } 12 13 func newRegistry() *registry { 14 r := new(registry) 15 r.store = make(map[string]*http.Transport) 16 17 return r 18 } 19 20 func (r *registry) get(key string) (*http.Transport, bool) { 21 r.RLock() 22 defer r.RUnlock() 23 24 // return r.store[key] does not work here, says too few argument to return 25 tr, ok := r.store[key] 26 return tr, ok 27 } 28 29 func (r *registry) put(key string, tr *http.Transport) { 30 r.Lock() 31 defer r.Unlock() 32 33 r.store[key] = tr 34 }