diff --git a/client/admin.go b/client/admin.go index b3485af2359778a49667277e57b735101dfe2a8b..364b3105eb3515c41d9885511f35f7d08856791b 100644 --- a/client/admin.go +++ b/client/admin.go @@ -37,7 +37,8 @@ func (svr *Service) RunAdminServer(address string) (err error) { user, passwd := svr.cfg.AdminUser, svr.cfg.AdminPwd router.Use(frpNet.NewHTTPAuthMiddleware(user, passwd).Middleware) - // api, see dashboard_api.go + // api, see admin_api.go + router.HandleFunc("/healthz", svr.healthz) router.HandleFunc("/api/reload", svr.apiReload).Methods("GET") router.HandleFunc("/api/status", svr.apiStatus).Methods("GET") router.HandleFunc("/api/config", svr.apiGetConfig).Methods("GET") diff --git a/client/admin_api.go b/client/admin_api.go index 49c2abfd1d8ba9f356488f912f71432363740178..a3540ff59a9c00e070d6fcc3469b2bc6a1bc02dc 100644 --- a/client/admin_api.go +++ b/client/admin_api.go @@ -32,6 +32,11 @@ type GeneralResponse struct { Msg string } +// /healthz +func (svr *Service) healthz(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) +} + // GET api/reload func (svr *Service) apiReload(w http.ResponseWriter, r *http.Request) { res := GeneralResponse{Code: 200} diff --git a/server/dashboard.go b/server/dashboard.go index edac675e54640c15315c168701ec36d3a41c3e16..7defec3cc88f27ba5d23f777aad5a64a6f5fbccc 100644 --- a/server/dashboard.go +++ b/server/dashboard.go @@ -48,6 +48,7 @@ func (svr *Service) RunDashboardServer(address string) (err error) { router.HandleFunc("/api/proxy/{type}", svr.APIProxyByType).Methods("GET") router.HandleFunc("/api/proxy/{type}/{name}", svr.APIProxyByTypeAndName).Methods("GET") router.HandleFunc("/api/traffic/{name}", svr.APIProxyTraffic).Methods("GET") + router.HandleFunc("/healthz", svr.Healthz) // view router.Handle("/favicon.ico", http.FileServer(assets.FileSystem)).Methods("GET") diff --git a/server/dashboard_api.go b/server/dashboard_api.go index d3100c846b2db01e03cf08d77d0b07a76cb0933b..7d159c7a89adf6e465e42e6051a941519f5acd40 100644 --- a/server/dashboard_api.go +++ b/server/dashboard_api.go @@ -51,6 +51,11 @@ type serverInfoResp struct { ProxyTypeCounts map[string]int64 `json:"proxy_type_count"` } +// /healthz +func (svr *Service) Healthz(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) +} + // api/serverinfo func (svr *Service) APIServerInfo(w http.ResponseWriter, r *http.Request) { res := GeneralResponse{Code: 200}