From 5d9ee59908099df3f7e85679f7384c98d4ac8111 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Tue, 28 Jul 2015 08:57:21 -0700 Subject: [PATCH] address CR comment re interface in cmds http handler https://github.com/ipfs/go-ipfs/pull/1529#discussion_r35662230 License: MIT Signed-off-by: Juan Batiz-Benet --- commands/http/handler.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/commands/http/handler.go b/commands/http/handler.go index a361aee18..e82acd3e2 100644 --- a/commands/http/handler.go +++ b/commands/http/handler.go @@ -70,13 +70,15 @@ type ServerConfig struct { func skipAPIHeader(h string) bool { switch h { + case "Access-Control-Allow-Origin": + return true + case "Access-Control-Allow-Methods": + return true + case "Access-Control-Allow-Credentials": + return true default: return false - case "Access-Control-Allow-Origin": - case "Access-Control-Allow-Methods": - case "Access-Control-Allow-Credentials": } - return true } func NewHandler(ctx cmds.Context, root *cmds.Command, cfg *ServerConfig) *Handler { @@ -151,7 +153,7 @@ func (i internalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // now handle responding to the client properly - sendResponse(w, r, req, res) + sendResponse(w, r, res, req) } func guessMimeType(res cmds.Response) (string, error) { @@ -167,7 +169,7 @@ func guessMimeType(res cmds.Response) (string, error) { return mimeTypes[enc], nil } -func sendResponse(w http.ResponseWriter, r *http.Request, req cmds.Request, res cmds.Response) { +func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req cmds.Request) { mime, err := guessMimeType(res) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError)