rename to mocksnow
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"mocksnow/server/models"
|
||||
)
|
||||
|
||||
// NewSnow receives data from the DMSP Snow New() function
|
||||
@@ -19,4 +21,15 @@ func (h *Handler) NewSnow(w http.ResponseWriter, r *http.Request) {
|
||||
} else {
|
||||
h.Logger.Debug("received input data", "length", len(reqBody))
|
||||
}
|
||||
|
||||
// Decode the JSON body
|
||||
var inc models.Incident
|
||||
if err := json.Unmarshal(reqBody, &inc); err != nil {
|
||||
h.Logger.Error("unable to decode json", "error", err)
|
||||
http.Error(w, "Invalid JSON body", http.StatusBadRequest)
|
||||
return
|
||||
} else {
|
||||
h.Logger.Debug("successfully decoded JSON")
|
||||
prettyPrint(inc)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user