You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2016/10/28 21:06:51 UTC

[28/50] incubator-trafficcontrol git commit: Fix TM2 duplicate file handling

Fix TM2 duplicate file handling


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/95095102
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/95095102
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/95095102

Branch: refs/heads/master
Commit: 9509510277d8209763d73aa6355d9c363e3ecdf0
Parents: e7a5fb6
Author: Robert Butts <ro...@gmail.com>
Authored: Thu Oct 20 10:39:33 2016 -0600
Committer: Jeremy Mitchell <mi...@gmail.com>
Committed: Fri Oct 28 15:04:12 2016 -0600

----------------------------------------------------------------------
 .../traffic_monitor/http_server/http_server.go        | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/95095102/traffic_monitor/experimental/traffic_monitor/http_server/http_server.go
----------------------------------------------------------------------
diff --git a/traffic_monitor/experimental/traffic_monitor/http_server/http_server.go b/traffic_monitor/experimental/traffic_monitor/http_server/http_server.go
index 6206cfd..a0a18dd 100644
--- a/traffic_monitor/experimental/traffic_monitor/http_server/http_server.go
+++ b/traffic_monitor/experimental/traffic_monitor/http_server/http_server.go
@@ -265,17 +265,15 @@ func (s Server) dataRequest(w http.ResponseWriter, req *http.Request, t Type, f
 }
 
 func (s Server) handleRootFunc() (http.HandlerFunc, error) {
-	index, err := ioutil.ReadFile("index.html")
-	if err != nil {
-		return nil, err
-	}
-	return func(w http.ResponseWriter, req *http.Request) {
-		fmt.Fprintf(w, "%s", index)
-	}, nil
+	return handleFile("index.html")
 }
 
 func (s Server) handleSortableFunc() (http.HandlerFunc, error) {
-	index, err := ioutil.ReadFile("sorttable.js")
+	return handleFile("sorttable.js")
+}
+
+func (s Server) handleFile(name string) (http.HandlerFunc, error) {
+	index, err := ioutil.ReadFile(file)
 	if err != nil {
 		return nil, err
 	}