add healthz api (#2511)

This commit is contained in:
fatedier
2021-08-04 14:33:53 +08:00
committed by GitHub
parent f570dcb307
commit 82f80a22be
4 changed files with 13 additions and 1 deletions

View File

@@ -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")

View File

@@ -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}