From 4b9fa9c97c86c30f4aa6cc84af778a10c1a6fdd7 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Sun, 16 Nov 2014 00:45:51 -0800 Subject: [PATCH] commands/http: Use constants for header names --- commands/http/handler.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/commands/http/handler.go b/commands/http/handler.go index 2a2e3ff8c..658d6ebe4 100644 --- a/commands/http/handler.go +++ b/commands/http/handler.go @@ -18,7 +18,10 @@ type Handler struct { var ErrNotFound = errors.New("404 page not found") -const streamHeader = "X-Stream-Output" +const ( + streamHeader = "X-Stream-Output" + contentTypeHeader = "Content-Type" +) var mimeTypes = map[string]string{ cmds.JSON: "application/json", @@ -63,7 +66,7 @@ func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } mime := mimeTypes[enc] - w.Header().Set("Content-Type", mime) + w.Header().Set(contentTypeHeader, mime) } // if response contains an error, write an HTTP error status code @@ -78,7 +81,7 @@ func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { out, err := res.Reader() if err != nil { w.WriteHeader(http.StatusInternalServerError) - w.Header().Set("Content-Type", "text/plain") + w.Header().Set(contentTypeHeader, "text/plain") w.Write([]byte(err.Error())) return }