Added: Bug Fixes

This commit is contained in:
shreyvishal
2025-06-25 16:30:47 +05:30
parent 02c69b98b6
commit 7a0a78d43d
12 changed files with 405 additions and 104 deletions

View File

@@ -0,0 +1,35 @@
package handler
import (
"encoding/json"
"fmt"
"net/http"
)
// HealthCheckResponse defines the structure for our health check JSON response.
type healthCheckResponse struct {
Status string `json:"status"`
Service string `json:"service"`
}
// healthHandler handles requests to the /health endpoint.
func HealthHandler(w http.ResponseWriter, r *http.Request) {
// Ensure the request method is GET.
if r.Method != http.MethodGet {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
return
}
w.Header().Set("Content-Type", "application/json")
response := healthCheckResponse{
Status: "ok",
Service: "beckn-adapter",
}
if err := json.NewEncoder(w).Encode(response); err != nil {
http.Error(w, "Error encoding response", http.StatusInternalServerError)
fmt.Printf("Error encoding health check response: %v\n", err)
return
}
}