mirror of
https://github.com/skidoodle/ipinfo.git
synced 2026-04-28 09:27:35 +02:00
31 lines
504 B
Go
31 lines
504 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log/slog"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
resp, err := http.Get("http://localhost:3000/health")
|
|
if err != nil {
|
|
slog.Error("error performing healthcheck", "err", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
defer func() {
|
|
if cerr := resp.Body.Close(); err != nil {
|
|
slog.Warn("failed to close response body", "err", cerr)
|
|
}
|
|
}()
|
|
|
|
if resp.StatusCode != http.StatusOK {
|
|
slog.Error("healthcheck failed", "status", resp.StatusCode)
|
|
os.Exit(1)
|
|
}
|
|
|
|
fmt.Println("OK")
|
|
os.Exit(0)
|
|
}
|