fix content-type
This commit is contained in:
parent
6349e97fdf
commit
a2f72a8c42
1 changed files with 2 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"mime"
|
"mime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IndexHandler(rw http.ResponseWriter, req *http.Request) {
|
func IndexHandler(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
|
@ -33,7 +34,7 @@ func StaticHandler(rw http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
rw.Header().Set("Content-Type", mime.TypeByExtension(path))
|
rw.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(path)))
|
||||||
io.Copy(rw, f)
|
io.Copy(rw, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue