1
0
fatedier 3 жил өмнө
parent
commit
82f80a22be

+ 2 - 1
client/admin.go

@@ -37,7 +37,8 @@ func (svr *Service) RunAdminServer(address string) (err error) {
 	user, passwd := svr.cfg.AdminUser, svr.cfg.AdminPwd
 	user, passwd := svr.cfg.AdminUser, svr.cfg.AdminPwd
 	router.Use(frpNet.NewHTTPAuthMiddleware(user, passwd).Middleware)
 	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/reload", svr.apiReload).Methods("GET")
 	router.HandleFunc("/api/status", svr.apiStatus).Methods("GET")
 	router.HandleFunc("/api/status", svr.apiStatus).Methods("GET")
 	router.HandleFunc("/api/config", svr.apiGetConfig).Methods("GET")
 	router.HandleFunc("/api/config", svr.apiGetConfig).Methods("GET")

+ 5 - 0
client/admin_api.go

@@ -32,6 +32,11 @@ type GeneralResponse struct {
 	Msg  string
 	Msg  string
 }
 }
 
 
+// /healthz
+func (svr *Service) healthz(w http.ResponseWriter, r *http.Request) {
+	w.WriteHeader(200)
+}
+
 // GET api/reload
 // GET api/reload
 func (svr *Service) apiReload(w http.ResponseWriter, r *http.Request) {
 func (svr *Service) apiReload(w http.ResponseWriter, r *http.Request) {
 	res := GeneralResponse{Code: 200}
 	res := GeneralResponse{Code: 200}

+ 1 - 0
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}", svr.APIProxyByType).Methods("GET")
 	router.HandleFunc("/api/proxy/{type}/{name}", svr.APIProxyByTypeAndName).Methods("GET")
 	router.HandleFunc("/api/proxy/{type}/{name}", svr.APIProxyByTypeAndName).Methods("GET")
 	router.HandleFunc("/api/traffic/{name}", svr.APIProxyTraffic).Methods("GET")
 	router.HandleFunc("/api/traffic/{name}", svr.APIProxyTraffic).Methods("GET")
+	router.HandleFunc("/healthz", svr.Healthz)
 
 
 	// view
 	// view
 	router.Handle("/favicon.ico", http.FileServer(assets.FileSystem)).Methods("GET")
 	router.Handle("/favicon.ico", http.FileServer(assets.FileSystem)).Methods("GET")

+ 5 - 0
server/dashboard_api.go

@@ -51,6 +51,11 @@ type serverInfoResp struct {
 	ProxyTypeCounts map[string]int64 `json:"proxy_type_count"`
 	ProxyTypeCounts map[string]int64 `json:"proxy_type_count"`
 }
 }
 
 
+// /healthz
+func (svr *Service) Healthz(w http.ResponseWriter, r *http.Request) {
+	w.WriteHeader(200)
+}
+
 // api/serverinfo
 // api/serverinfo
 func (svr *Service) APIServerInfo(w http.ResponseWriter, r *http.Request) {
 func (svr *Service) APIServerInfo(w http.ResponseWriter, r *http.Request) {
 	res := GeneralResponse{Code: 200}
 	res := GeneralResponse{Code: 200}