added sql storage
This commit is contained in:
@@ -22,12 +22,6 @@ type JSONMessage struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type LogMessage struct {
|
||||
Level int `json:"level"`
|
||||
Namespace string `json:"namespace"`
|
||||
Payload interface{} `json:"payload"`
|
||||
}
|
||||
|
||||
func apiInfo(w http.ResponseWriter, req *http.Request) {
|
||||
version := struct {
|
||||
Version string `json:"version"`
|
||||
@@ -64,13 +58,12 @@ func put(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
parse_err := json.Unmarshal(body, &message)
|
||||
if parse_err != nil {
|
||||
if err := json.NewEncoder(w).Encode(JSONError{parse_err.Error()}); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
b, _ := json.Marshal(JSONError{err.Error()})
|
||||
http.Error(w, string(b), http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = json.Marshal(message.Payload)
|
||||
_, err = message.save()
|
||||
if err != nil {
|
||||
b, _ := json.Marshal(JSONError{err.Error()})
|
||||
http.Error(w, string(b), http.StatusMethodNotAllowed)
|
||||
|
||||
Reference in New Issue
Block a user