set known mimetypes while streaming

This commit is contained in:
sentriz
2020-02-21 01:43:27 +00:00
parent e9ca7fba64
commit 6de50dc865

View File

@@ -8,6 +8,7 @@ import (
"github.com/jinzhu/gorm"
"senan.xyz/g/gonic/db"
"senan.xyz/g/gonic/mime"
"senan.xyz/g/gonic/server/ctrlsubsonic/params"
"senan.xyz/g/gonic/server/ctrlsubsonic/spec"
)
@@ -65,8 +66,10 @@ func (c *Controller) ServeStream(w http.ResponseWriter, r *http.Request) *spec.R
track.Album.RightPath,
track.Filename,
)
if mime, ok := mime.Types[track.Ext()]; ok {
w.Header().Set("Content-Type", mime)
}
http.ServeFile(w, r, absPath)
//
// after we've served the file, mark the album as played
user := r.Context().Value(CtxUser).(*db.User)
play := db.Play{