mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-21 00:29:03 +01:00
29 lines
465 B
Go
29 lines
465 B
Go
package healthcheck
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/yusing/godoxy/internal/types"
|
|
)
|
|
|
|
func FileServer(path string) (types.HealthCheckResult, error) {
|
|
start := time.Now()
|
|
_, err := os.Stat(path)
|
|
lat := time.Since(start)
|
|
|
|
if err != nil {
|
|
if os.IsNotExist(err) {
|
|
return types.HealthCheckResult{
|
|
Detail: err.Error(),
|
|
}, nil
|
|
}
|
|
return types.HealthCheckResult{}, err
|
|
}
|
|
|
|
return types.HealthCheckResult{
|
|
Healthy: true,
|
|
Latency: lat,
|
|
}, nil
|
|
}
|