Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
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
}