Log response. Fix #116

This commit is contained in:
iacore
2024-09-24 18:46:00 +00:00
parent 18d6874e89
commit ee2f2ba104
+11 -11
View File
@@ -71,6 +71,17 @@ func retryRequest(ctx context.Context, reqFunc func(context.Context, string) (*r
resp, err := retryClient.Do(req)
end := time.Now()
audit.LogAPIRoundTrip(audit.APIRequestSpan{
RequestId: request_context.GetFromContext(ctx).RequestId,
Response: resp,
Error: err,
Method: req.Method,
Token: tokenValue,
Body: "",
StartTime: start,
EndTime: end,
})
if err == nil && resp.StatusCode == http.StatusOK {
if userToken == "" && !isPost {
tokenManager.MarkTokenStatus(token, token_manager.Good)
@@ -95,17 +106,6 @@ func retryRequest(ctx context.Context, reqFunc func(context.Context, string) (*r
tokenManager.MarkTokenStatus(token, token_manager.TimedOut)
}
audit.LogAPIRoundTrip(audit.APIRequestSpan{
RequestId: request_context.GetFromContext(ctx).RequestId,
Response: resp,
Error: err,
Method: req.Method,
Token: tokenValue,
Body: "",
StartTime: start,
EndTime: end,
})
select {
case <-ctx.Done():
return SimpleHTTPResponse{}, ctx.Err()