}
w.Write(b)
+ w.WriteHeader(http.StatusOK)
}
w.WriteHeader(http.StatusOK)
}
-/** TODO TEST
- *
+/** TEST
+ * Method to get a specific song by ID
**/
func (dbw *DBWrapper) SongsGetById(w http.ResponseWriter, r *http.Request) {
+ // the ID should be as 'song:XX' in the KEY section of DB song
+ // then all the non-zero / non-empty fields will be updated on that song
+ newSong := DBSong{}
+ err := json.NewDecoder(r.Body).Decode(&newSong)
+ if err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+ newSong, err = dbw.getSongByKey(newSong.Key)
+ if err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+
+ b, err := json.Marshal(newSong)
+ if err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+
+ w.Write(b)
+ w.WriteHeader(http.StatusOK)
}
/** TODO TEST
*
**/
func (dbw *DBWrapper) SongsDeleteById(w http.ResponseWriter, r *http.Request) {
+
}