added sql storage

This commit is contained in:
sm
2013-12-21 00:26:54 -08:00
parent c7f600f8e7
commit 5732f06932
5 changed files with 81 additions and 11 deletions
+3 -10
View File
@@ -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)