Add Go rewrite with Postgres 17 and Dokploy Docker Compose

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
orohi
2026-07-27 08:21:21 +03:00
co-authored by Cursor
parent bac78dd3fc
commit 99a27f00be
67 changed files with 17864 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package handlers
import (
"context"
"net/http"
"time"
"amnezia-share/internal/web"
)
func registerHealth(a *web.App, mux *http.ServeMux) {
mux.HandleFunc("GET /health", Health(a))
}
// Health reports basic liveness plus a DB ping, mirroring health.php.
func Health(a *web.App) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
dbOK := true
ctx, cancel := context.WithTimeout(r.Context(), 3*time.Second)
defer cancel()
if err := a.Pool.Ping(ctx); err != nil {
dbOK = false
}
status := http.StatusOK
if !dbOK {
status = http.StatusServiceUnavailable
}
writeJSON(w, status, map[string]any{
"ok": dbOK,
"db": dbOK,
"time": time.Now().UTC().Format(time.RFC3339),
})
}
}