私はhttp:ファイルサーバーを使って、私のテンプレートであるsrc
をmp3ファイルのディレクトリとして提供しています。ただし、応答にはaudio/mpeg
の代わりにContent-Type
text/html
が使用されます。 FileServerが応答するMIMEタイプを設定するには、この質問Setting the 'charset' property on the Content-Type header in the golang HTTP FileServerを見ましたが、MIMEタイプをオーバーライドする方法がまだわかりません。間違ったMIMEを持つhttp.FileServerの応答 "Content-Type"
私のコードは次のようになります。
fs := http.FileServer(http.Dir(dir))
http.Handle("/media", http.StripPrefix("/media", fs))
http.HandleFunc("/", p.playlistHandler)
http.ListenAndServe(":5177", nil)
と私が得るエラーは次のとおりです。
HTTP "Content-Type" of "text/html" is not supported. Load of media resource http://localhost:5177/media/sample1.mp3 failed.