feat: finish project basic structure and core functions

This commit is contained in:
2026-08-03 22:15:53 +08:00
parent 3ab175b595
commit 19b69acc29
29 changed files with 3864 additions and 2 deletions
+28
View File
@@ -0,0 +1,28 @@
package handler
import (
"net/http"
"nukumizu-backend/database"
"nukumizu-backend/utils"
)
// HealthHandler handles GET /health.
func HealthHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
utils.SendErrorResponse(w, http.StatusMethodNotAllowed, "method not allowed")
return
}
dbStatus := "ok"
if database.UserDB == nil {
dbStatus = "not initialized"
} else if err := database.UserDB.Ping(); err != nil {
dbStatus = "error: " + err.Error()
}
utils.SendSuccessResponse(w, "", map[string]interface{}{
"status": "ok",
"database": dbStatus,
})
}