func (r *Router) Unregister(unprox proxy.ApiProxySpec) { met := unprox.GetMethod() if r.proxies[met] != nil { for i, p := range r.proxies[met] { if p.GetPattern() == unprox.GetPattern() { r.mutex.Lock() defer r.mutex.Unlock() //remove the element in the `i` position r.proxies[met] = append(r.proxies[met][:i], r.proxies[met][i+1:]...) // (1,2,...,i,...n)~>(1,2,..,i-1,i+1,...n) } } } return }
func (r *Router) Register(p proxy.ApiProxySpec) { r.Add(strings.ToUpper(p.GetMethod()), p) }