From fa85c84af34039521c1a765e11361fe10e026ff6 Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Thu, 2 Oct 2025 21:48:03 +0800 Subject: [PATCH] chore: code refactoring (#5204) --- rest/handler/loghandler.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/rest/handler/loghandler.go b/rest/handler/loghandler.go index f28e0d262..5801f4305 100644 --- a/rest/handler/loghandler.go +++ b/rest/handler/loghandler.go @@ -127,6 +127,14 @@ func dumpRequest(r *http.Request) string { return string(reqContent) } +func getSlowThreshold(r *http.Request) time.Duration { + if r.Header.Get(headerAccept) == valueSSE { + return sseSlowThreshold.Load() + } else { + return slowThreshold.Load() + } +} + func isOkResponse(code int) bool { // not server error return code < http.StatusInternalServerError @@ -234,12 +242,3 @@ func wrapStatusCode(code int) string { return logx.WithColorPadding(strconv.Itoa(code), colour) } - -func getSlowThreshold(r *http.Request) time.Duration { - threshold := slowThreshold.Load() - if r.Header.Get(headerAccept) == valueSSE { - threshold = sseSlowThreshold.Load() - } - - return threshold -}