diff --git a/mpd.go b/mpd.go index 12bac1c..80943d9 100644 --- a/mpd.go +++ b/mpd.go @@ -11,6 +11,22 @@ import ( // MPD API calls +func updateDb(c echo.Context) error { + // Connect to MPD server + conn, err := mpd.Dial("tcp", "localhost:6600") + if err != nil { + log.Fatalln(err) + } + defer conn.Close() + + jobId, err := conn.Update("") + if err != nil { + log.Fatalln(err) + } + + return c.String(http.StatusOK, strconv.Itoa(jobId)) +} + func previousTrack(c echo.Context) error { // Connect to MPD server conn, err := mpd.Dial("tcp", "localhost:6600") diff --git a/server.go b/server.go index fbd02c5..8095f32 100644 --- a/server.go +++ b/server.go @@ -78,6 +78,7 @@ func main() { }) g := e.Group("/api") + g.GET("/update_db", updateDb) g.GET("/previous_track", previousTrack) g.GET("/next_track", nextTrack) g.GET("/stop", stopPlayback)