set content type

master
Bel LaPointe 2021-04-20 07:40:13 -05:00
parent 90dbfd6f5a
commit 94a14f8b9d
1 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"local/gziphttp" "local/gziphttp"
"local/oauth2/oauth2client" "local/oauth2/oauth2client"
"local/router" "local/router"
"local/simpleserve/simpleserve"
"local/todo-server/config" "local/todo-server/config"
"log" "log"
"net/http" "net/http"
@ -136,12 +137,14 @@ func (s *Server) _static(w http.ResponseWriter, r *http.Request) error {
return err return err
} }
if info.IsDir() { if info.IsDir() {
f, err = s.fileDir.Open(path.Join(r.URL.Path, "index.html")) r.URL.Path = path.Join(r.URL.Path, "index.html")
f, err = s.fileDir.Open(r.URL.Path)
defer f.Close() defer f.Close()
if err != nil { if err != nil {
return err return err
} }
} }
simpleserve.SetContentTypeIfMedia(w, r)
_, err = io.Copy(w, f) _, err = io.Copy(w, f)
return err return err
} }