|
|
@@ -7,10 +7,6 @@ import (
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-var (
|
|
|
- contentTypeJSONHeader = map[string]string{"ContentType": "application/json"}
|
|
|
-)
|
|
|
-
|
|
|
type API struct {
|
|
|
client *resty.Client
|
|
|
baseUrl string
|
|
|
@@ -32,12 +28,22 @@ func DestroyAPI(api *API) {
|
|
|
api.client = nil
|
|
|
}
|
|
|
|
|
|
-func (api *API) PostJSON(methodName string, data []byte) ([]byte, error) {
|
|
|
- return api.Post(methodName, contentTypeJSONHeader, data)
|
|
|
+func (api *API) PostJSON(methodName string, data []byte, headers map[string]string) ([]byte, error) {
|
|
|
+ if headers == nil {
|
|
|
+ headers = make(map[string]string)
|
|
|
+ }
|
|
|
+
|
|
|
+ headers["Content-Type"] = "application/json"
|
|
|
+ return api.Post(methodName, headers, data)
|
|
|
}
|
|
|
|
|
|
-func (api *API) PutJSON(methodName string, data []byte) ([]byte, error) {
|
|
|
- return api.Put(methodName, contentTypeJSONHeader, data)
|
|
|
+func (api *API) PutJSON(methodName string, data []byte, headers map[string]string) ([]byte, error) {
|
|
|
+ if headers == nil {
|
|
|
+ headers = make(map[string]string)
|
|
|
+ }
|
|
|
+
|
|
|
+ headers["Content-Type"] = "application/json"
|
|
|
+ return api.Put(methodName, headers, data)
|
|
|
}
|
|
|
|
|
|
func (api *API) PostWithoutHeaders(methodName string, data []byte) ([]byte, error) {
|