This commit is contained in:
2026-01-27 13:20:03 +08:00
parent ac0ff00880
commit 98f1705f72
3 changed files with 10 additions and 11 deletions
+8 -9
View File
@@ -2,20 +2,19 @@ package handlers
import (
"authentication/db"
"authentication/helper"
"authentication/models"
"authentication/redisclient"
"context"
"encoding/json"
"net/http"
"time"
)
func HealthHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(models.HealthResponse{
Status: "ok",
})
response := models.HealthResponse{
Status: "AuthN Capy!",
}
helper.RespondWithJSON(w, http.StatusOK, response)
}
// ReadyHandler checks if the service is ready to handle requests
@@ -62,15 +61,15 @@ func ReadyHandler(w http.ResponseWriter, r *http.Request) {
allHealthy = false
}
status := "ready"
status := "Capy!"
statusCode := http.StatusOK
if !allHealthy {
status = "not_ready"
status = "not Capy!"
statusCode = http.StatusServiceUnavailable
}
w.WriteHeader(statusCode)
json.NewEncoder(w).Encode(models.HealthResponse{
helper.RespondWithJSON(w, statusCode, models.HealthResponse{
Status: status,
Services: services,
})
+1 -1
View File
@@ -51,7 +51,7 @@ func init() {
keyPath = "rsa/psa.gov.ph.key"
}
keyData, err := os.ReadFile(keyPath)
keyData, err := os.ReadFile(keyPath) // #nosec G304
if err != nil {
if isTestEnvironment() {
log.Printf("Failed to read RSA private key file at %s, generating test key: %v", keyPath, err)
+1 -1
View File
@@ -11,7 +11,7 @@ import (
)
const (
csrfTokenHeader = "X-CSRF-Token"
csrfTokenHeader = "X-CSRF-Token" // #nosec G101
csrfCookieName = "csrf_token"
csrfTokenLength = 32
csrfTokenTTL = 24 * time.Hour