package api import ( "encoding/json" "fmt" "music-server/pkg/helpers" "music-server/pkg/server" "net/http" ) func IndexHandler(w http.ResponseWriter, r *http.Request) { helpers.SetCorsAndNoCacheHeaders(&w, r) if r.URL.Path == "/version" { w.Header().Add("Content-Type", "application/json") history := server.GetVersionHistory() _ = json.NewEncoder(w).Encode(history) } else if r.URL.Path == "/docs" { http.ServeFile(w, r, "./docs/swagger.yaml") } else if r.URL.Path == "/" { _, err := fmt.Fprint(w, "Hello, World!!") if err != nil { w.WriteHeader(http.StatusInternalServerError) } } else { http.NotFound(w, r) return } }