Skip to content

Commit

Permalink
address CR comment re interface in cmds http handler
Browse files Browse the repository at this point in the history
ipfs/kubo#1529 (comment)

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
  • Loading branch information
jbenet committed Jul 29, 2015
1 parent 135e1fc commit 0cd37df
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions http/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ type ServerConfig struct {

func skipAPIHeader(h string) bool {
switch h {
default:
return false
case "Access-Control-Allow-Origin":
return true
case "Access-Control-Allow-Methods":
return true
case "Access-Control-Allow-Credentials":
return true
default:
return false
}
return true
}

func NewHandler(ctx cmds.Context, root *cmds.Command, cfg *ServerConfig) *Handler {
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit 0cd37df

Please sign in to comment.