func GetSong(ctx *middleware.Context, w http.ResponseWriter, r *http.Request) (interface{}, error) { var s song.Song s.ID = bson.ObjectIdHex(ctx.Params.ByName("id")) err := s.Get() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return s, err } return s, nil }
func DeleteSong(ctx *middleware.Context, w http.ResponseWriter, r *http.Request) (interface{}, error) { var s song.Song s.ID = bson.ObjectIdHex(r.URL.Query().Get("id")) err := s.Delete() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return s, err } return s, nil }
func CreateSong(ctx *middleware.Context, w http.ResponseWriter, r *http.Request) (interface{}, error) { var s song.Song err := json.NewDecoder(r.Body).Decode(&s) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return s, err } err = s.Create() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return s, err } return s, nil }