improve response
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-24 10:52:00 +11:00
parent fe889a7a2c
commit 6b88436b37

View File

@@ -1,6 +1,7 @@
package handler
import (
"fmt"
"net/http"
"strings"
)
@@ -15,13 +16,18 @@ func (h *Handler) GetIncident(w http.ResponseWriter, r *http.Request) {
parts := strings.Split(path, "/")
h.Logger.Debug("Request path", "parts", parts)
if len(parts) != 6 || parts[1] != "api" || parts[2] != "now" || parts[3] != "table" || parts[4] != "incident" {
http.NotFound(w, r)
return
if len(parts) == 6 && strings.HasPrefix(path, "/api/now/table/incident/") {
// Requested a single incident
id := parts[5] // Extract {id}
h.Logger.Debug("GetIncident called for specific incident", "id", id)
} else if strings.HasPrefix(path, "/api/now/table/incident") {
h.Logger.Debug("GetIncident called for list of incidents")
}
id := parts[5] // Extract {id}
h.Logger.Debug("GetIncident called", "id", id)
//fmt.Fprintf(w, "Incident ID: %s", id)
// TODO - provide an incident list if necessary
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "{result: {}}")
}