Updated swagger file and version info

This commit is contained in:
2021-10-28 21:21:56 +02:00
parent a742aead0a
commit 015620add6
3 changed files with 20 additions and 12 deletions

View File

@@ -210,11 +210,11 @@ func musicHandler(w http.ResponseWriter, r *http.Request) {
}
} else {
s := getSong(song)
sendFile(w, s)
sendSong(w, s)
}
} else if r.URL.Path == "/music/first" && r.Method == http.MethodGet {
song := getSoundCheckSong()
sendFile(w, song)
sendSong(w, song)
} else if r.URL.Path == "/music/reset" && r.Method == http.MethodGet {
reset()
@@ -222,11 +222,11 @@ func musicHandler(w http.ResponseWriter, r *http.Request) {
} else if r.URL.Path == "/music/rand" && r.Method == http.MethodGet {
song := getRandomSong()
sendFile(w, song)
sendSong(w, song)
} else if r.URL.Path == "/music/rand/low" && r.Method == http.MethodGet {
chance := getRandomSongLowChance()
sendFile(w, chance)
sendSong(w, chance)
} else if r.URL.Path == "/music/info" && r.Method == http.MethodGet {
w.Header().Add("Content-Type", "application/json")
@@ -238,11 +238,11 @@ func musicHandler(w http.ResponseWriter, r *http.Request) {
} else if r.URL.Path == "/music/next" {
song := getNextSong()
sendFile(w, song)
sendSong(w, song)
} else if r.URL.Path == "/music/previous" {
song := getPreviousSong()
sendFile(w, song)
sendSong(w, song)
} else if r.URL.Path == "/music/all" && r.Method == http.MethodGet {
w.Header().Add("Content-Type", "application/json")
@@ -263,14 +263,14 @@ func musicHandler(w http.ResponseWriter, r *http.Request) {
}
}
func sendFile(writer http.ResponseWriter, Filename string) {
func sendSong(writer http.ResponseWriter, Filename string) {
fmt.Println("Client requests: " + Filename)
//Check if file exists and open
openFile, err := os.Open(Filename)
if err != nil {
//File not found, send 404
http.Error(writer, "File not found.", 404)
http.Error(writer, "Song not found.", 404)
return
}
defer func(openFile *os.File) {