forked from cheelim1/terraform-provider-jumpcloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor HTTP API calls to common func
- Loading branch information
1 parent
f56589b
commit c3bbb32
Showing
3 changed files
with
48 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package util | ||
|
||
import ( | ||
"io" | ||
"net/http" | ||
) | ||
|
||
// RequestHTTP encapsulates boilerplate related to making an HTTP request | ||
func RequestHTTP(method string, headers map[string]string, | ||
URL string, requestBody io.Reader) (res *http.Response, err error) { | ||
|
||
req, err := http.NewRequest(method, URL, requestBody) | ||
if err != nil { | ||
return | ||
} | ||
|
||
for k, v := range headers { | ||
req.Header.Add(k, v) | ||
} | ||
|
||
req.Header.Add("Content-Type", "application/json") | ||
req.Header.Add("Accept", "application/json") | ||
|
||
return http.DefaultClient.Do(req) | ||
} |