Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DVX: 554 - Bug: Replace hardcoded request headers to get from request directly #59

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -443,8 +444,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 @@ -501,7 +500,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 @@ -602,15 +600,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
Loading