コード例 #1
0
ファイル: albums.go プロジェクト: hoffoo/pickup
func (h AlbumHandler) searchAlbums(w http.ResponseWriter, query string) {
	matches := model.SearchAlbums(h.Music, query)
	fmt.Printf("Found %d results\n", len(matches))
	for _, item := range matches {
		fmt.Printf("%s - %s\n", item.Artist, item.Name)
	}
	j, _ := json.Marshal(matches)
	w.Write(j)
	return
}
コード例 #2
0
ファイル: albums.go プロジェクト: prietosanti/pickup
func (h AlbumHandler) searchAlbums(w http.ResponseWriter, query string) {
	log.Printf("Searching for albums matching  '%s'\n", query)
	music, err := h.GetCollection()
	if err != nil {
		log.Printf("Failed to connect to mpd")
		writeError(w, http.StatusNotFound, "Problem with mpd")
	}
	matches := model.SearchAlbums(music, query)
	log.Printf("Found %d results\n", len(matches))
	for _, item := range matches {
		log.Printf("%s - %s\n", item.Artist, item.Name)
	}
	j, _ := json.Marshal(matches)
	w.Write(j)
	return
}