Skip to content

Commit

Permalink
chore: Use DELETE to clear the proxy group fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
xishang0128 committed Sep 27, 2024
1 parent acfc9f8 commit af5ad32
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions hub/route/proxies.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func proxyRouter() http.Handler {
r.Get("/", getProxy)
r.Get("/delay", getProxyDelay)
r.Put("/", updateProxy)
r.Delete("/", unfixedProxy)
})
return r
}
Expand Down Expand Up @@ -146,3 +147,27 @@ func getProxyDelay(w http.ResponseWriter, r *http.Request) {
"delay": delay,
})
}

func unfixedProxy(w http.ResponseWriter, r *http.Request) {
proxy := r.Context().Value(CtxKeyProxy).(C.Proxy)
switch proxy.(*adapter.Proxy).Type() {
case C.URLTest:
if urlTestGroup, ok := proxy.(*adapter.Proxy).ProxyAdapter.(*outboundgroup.URLTest); ok {
urlTestGroup.ForceSet("")
}
case C.Fallback:
if fallbackGroup, ok := proxy.(*adapter.Proxy).ProxyAdapter.(*outboundgroup.Fallback); ok {
fallbackGroup.ForceSet("")
}
default:
render.Status(r, http.StatusBadRequest)
render.JSON(w, r, ErrBadRequest)
return
}

if proxy.(*adapter.Proxy).Type() != C.Selector {
cachefile.Cache().SetSelected(proxy.Name(), "")
}

render.NoContent(w, r)
}

0 comments on commit af5ad32

Please sign in to comment.