Exemple #1
0
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
}
Exemple #2
0
func (r *Router) Register(p proxy.ApiProxySpec) {
	r.Add(strings.ToUpper(p.GetMethod()), p)
}
Exemple #3
0
func (e *Engine) OnChangeProxy(target proxy.ApiProxySpec) {
	e.GetHandler().GetRouter().Register(target)
	logutils.PrintH2("Setting up api (%s) ... done", target.GetId())
}