diff --git a/server/handler/getIncident.go b/server/handler/getIncident.go index cbd38e9..53c91f4 100644 --- a/server/handler/getIncident.go +++ b/server/handler/getIncident.go @@ -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: {}}") }