From 94a14f8b9da73aa97a71194278dea218fd097319 Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Tue, 20 Apr 2021 07:40:13 -0500 Subject: [PATCH] set content type --- server/routes.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/routes.go b/server/routes.go index 39230c9..36f154c 100755 --- a/server/routes.go +++ b/server/routes.go @@ -6,6 +6,7 @@ import ( "local/gziphttp" "local/oauth2/oauth2client" "local/router" + "local/simpleserve/simpleserve" "local/todo-server/config" "log" "net/http" @@ -136,12 +137,14 @@ func (s *Server) _static(w http.ResponseWriter, r *http.Request) error { return err } 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() if err != nil { return err } } + simpleserve.SetContentTypeIfMedia(w, r) _, err = io.Copy(w, f) return err }