refactor(health): optimize health checking

This commit is contained in:
yusing
2025-09-27 11:32:18 +08:00
parent e2aeef3a86
commit b2713a4b83
11 changed files with 123 additions and 83 deletions

View File

@@ -22,8 +22,10 @@ func CheckHealth(w http.ResponseWriter, r *http.Request) {
return
}
var result *types.HealthCheckResult
var err error
var (
result types.HealthCheckResult
err error
)
switch scheme {
case "fileserver":
path := query.Get("path")
@@ -32,7 +34,7 @@ func CheckHealth(w http.ResponseWriter, r *http.Request) {
return
}
_, err := os.Stat(path)
result = &types.HealthCheckResult{Healthy: err == nil}
result = types.HealthCheckResult{Healthy: err == nil}
if err != nil {
result.Detail = err.Error()
}