Skip to content

Commit

Permalink
HTTP Response handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aborroy committed May 4, 2023
1 parent 8d3a0d8 commit bcc3a94
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions httpclient/http-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ type HttpExecution struct {
ResponseBodyOutput io.Writer
}

var validHttpResponse = map[int]bool{
http.StatusOK: true,
http.StatusCreated: true,
http.StatusNoContent: true,
}

func setBasicAuthHeader(request *http.Request, username, password string) {
if cmd.UsernameParam != "" {
username = cmd.UsernameParam
Expand Down Expand Up @@ -61,12 +67,6 @@ func createHttpClient(tlsEnabled bool, insecureAllowed bool) *http.Client {
return &client
}

var validHttpResponse = map[int]bool{
http.StatusOK: true,
http.StatusCreated: true,
http.StatusNoContent: true,
}

func checkStatusResponse(httpStatus int) {
if !validHttpResponse[httpStatus] {
fmt.Println("HTTP ERROR", httpStatus, http.StatusText(httpStatus))
Expand Down

0 comments on commit bcc3a94

Please sign in to comment.