From ee2f2ba10475c83816de2429e68e1f969921dc98 Mon Sep 17 00:00:00 2001 From: iacore Date: Tue, 24 Sep 2024 18:46:00 +0000 Subject: [PATCH] Log response. Fix #116 --- core/requests.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/core/requests.go b/core/requests.go index 5082017..d7bca21 100644 --- a/core/requests.go +++ b/core/requests.go @@ -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()