Skip to content

Commit

Permalink
Merge pull request #59 from atlanhq/DVX-554-Making-logging-consistent
Browse files Browse the repository at this point in the history
DVX: 554 - Bug: Replace hardcoded request headers to get from request directly
  • Loading branch information
0xquark authored Sep 12, 2024
2 parents 5f22cb8 + 79e4a22 commit 839e7cb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions atlan/assets/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type AtlanClient struct {
var (
DefaultAtlanClient *AtlanClient
DefaultAtlanTagCache *AtlanTagCache
contentType string
)

// Init initializes the default AtlanClient.
Expand Down Expand Up @@ -447,8 +448,6 @@ func (ac *AtlanClient) CallAPI(api *API, queryParams interface{}, requestObj int
}
}

ac.logAPICall(api.Method, path)

// Send the request
response, err := ac.makeRequest(api.Method, path, params)
if err != nil {
Expand Down Expand Up @@ -505,7 +504,6 @@ func (ac *AtlanClient) CallAPI(api *API, queryParams interface{}, requestObj int
func (ac *AtlanClient) makeRequest(method, path string, params map[string]interface{}) (*http.Response, error) {
var req *http.Request
var err error
var contentType string

switch method {
case http.MethodGet:
Expand Down Expand Up @@ -606,15 +604,17 @@ func (ac *AtlanClient) makeRequest(method, path string, params map[string]interf
req.URL.RawQuery = query
}

ac.logAPICall(req.Method, path, req)

// Finally, execute the request
return ac.Session.Do(req)
}

func (ac *AtlanClient) logAPICall(method, path string) {
func (ac *AtlanClient) logAPICall(method, path string, request *http.Request) {
ac.logger.Debugf("------------------------------------------------------")
ac.logger.Debugf("Call : %s %s", method, path)
ac.logger.Debugf("Content-type : application/json")
ac.logger.Debugf("Accept : application/json")
ac.logger.Debugf("Content-type : %s", request.Header.Get("Content-Type"))
ac.logger.Debugf("Accept : %s", request.Header.Get("Accept"))
}

func (ac *AtlanClient) logHTTPStatus(response *http.Response) {
Expand Down

0 comments on commit 839e7cb

Please sign in to comment.