From 5b60435ee03290a54778412dee3d7f432b81b3d3 Mon Sep 17 00:00:00 2001 From: Suraj Date: Mon, 1 Feb 2016 20:04:01 +0530 Subject: [PATCH] removed static files handler --- views/views.go | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/views/views.go b/views/views.go index 9fa1ae8..17ba899 100644 --- a/views/views.go +++ b/views/views.go @@ -1,10 +1,9 @@ package views +/*Holds the fetch related view handlers*/ + import ( - "bufio" "net/http" - "os" - "strings" "text/template" "time" @@ -74,31 +73,3 @@ func ShowCompleteTasksFunc(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/", http.StatusFound) } } - -//ServeStaticFunc is used to serve static files -//TODO: replace this with the http.FileServer -func ServeStaticFunc(w http.ResponseWriter, r *http.Request) { - path := "./public" + r.URL.Path - var contentType string - if strings.HasSuffix(path, ".css") { - contentType = "text/css" - } else if strings.HasSuffix(path, ".png") { - contentType = "image/png" - } else if strings.HasSuffix(path, ".js") { - contentType = "application/javascript" - } else { - contentType = "plain/text" - } - - f, err := os.Open(path) - - if err == nil { - defer f.Close() - w.Header().Add("Content Type", contentType) - - br := bufio.NewReader(f) - br.WriteTo(w) - } else { - w.WriteHeader(404) - } -}