duplicate path variable parsing removed
This commit is contained in:
parent
10e3025ddc
commit
e29c7be4fa
14
main.go
14
main.go
@ -80,10 +80,13 @@ func GetAllHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetFileHandler(w http.ResponseWriter, r *http.Request) {
|
func GetFileHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
fileName, err := url.QueryUnescape(mux.Vars(r)["file"])
|
||||||
file := vars["file"]
|
if err != nil {
|
||||||
|
InternalServerError(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
http.ServeFile(w, r, filepath.Join(LibraryPath, ".songs", file))
|
http.ServeFile(w, r, filepath.Join(LibraryPath, ".songs", fileName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPlaylistHandler(w http.ResponseWriter, r *http.Request) {
|
func GetPlaylistHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -141,8 +144,9 @@ func GetAllFilesHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetEncodeFileHandler(w http.ResponseWriter, r *http.Request) {
|
func GetEncodeFileHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
format := mux.Vars(r)["format"]
|
vars := mux.Vars(r)
|
||||||
fileName, err := url.QueryUnescape(mux.Vars(r)["file"])
|
format := vars["format"]
|
||||||
|
fileName, err := url.QueryUnescape(vars["file"])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InternalServerError(w, err)
|
InternalServerError(w, err)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user