commit dad28b1a8f4f17dd47854db715221aa985024cef from: Oliver Lowe date: Thu Dec 30 07:50:08 2021 UTC set correct request Content-Type and Accept values in header commit - 007a3d09eccd162b288c0584b68b0fdb83becf11 commit + dad28b1a8f4f17dd47854db715221aa985024cef blob - 7d82adcaf6357ddeada7d8d34d91598ff5c67b7e blob + 810fea563b939b4c0aa461ae72c010838d6bea8e --- http.go +++ http.go @@ -1,7 +1,6 @@ package icinga import ( - "encoding/json" "io" "net/http" ) @@ -15,8 +14,15 @@ func newRequest(method, host, path string, body io.Rea return nil, err } switch req.Method { + case http.MethodGet: + break + case http.MethodDelete: + req.Header.Set("Accept", "application/json") case http.MethodPost, http.MethodPut: + req.Header.Set("Accept", "application/json") req.Header.Set("Content-Type", "application/json") + default: + return nil, fmt.Errorf("new request: unsupported method %s", req.Method) } return req, nil }