@cryptotaxi247 / kubo / commits / 5d9ee5990

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 <juan@benet.ai>

Juan Batiz-Benet committed Jul 28, 2015 at 08:57 UTC 5d9ee59908099df3f7e85679f7384c98d4ac8111
1 file changed +7 -5
commands/http/handler.go
+7 -5
@@ -70,13 +70,15 @@ type ServerConfig struct {
70
71 func skipAPIHeader(h string) bool {
72 switch h {
73 - default:
74 - return false
73 case "Access-Control-Allow-Origin":
74 + return true
75 case "Access-Control-Allow-Methods":
76 + return true
77 case "Access-Control-Allow-Credentials":
78 + return true
79 + default:
80 + return false
81 }
79 - return true
82 }
83
84 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) {
153 }
154
155 // now handle responding to the client properly
154 - sendResponse(w, r, req, res)
156 + sendResponse(w, r, res, req)
157 }
158
159 func guessMimeType(res cmds.Response) (string, error) {
@@ -167,7 +169,7 @@ func guessMimeType(res cmds.Response) (string, error) {
169 return mimeTypes[enc], nil
170 }
171
170 -func sendResponse(w http.ResponseWriter, r *http.Request, req cmds.Request, res cmds.Response) {
172 +func sendResponse(w http.ResponseWriter, r *http.Request, res cmds.Response, req cmds.Request) {
173 mime, err := guessMimeType(res)
174 if err != nil {
175 http.Error(w, err.Error(), http.StatusInternalServerError)