Skip to content

Commit fa85c84

Browse files
authored
chore: code refactoring (#5204)
1 parent 4408841 commit fa85c84

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

rest/handler/loghandler.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ func dumpRequest(r *http.Request) string {
127127
return string(reqContent)
128128
}
129129

130+
func getSlowThreshold(r *http.Request) time.Duration {
131+
if r.Header.Get(headerAccept) == valueSSE {
132+
return sseSlowThreshold.Load()
133+
} else {
134+
return slowThreshold.Load()
135+
}
136+
}
137+
130138
func isOkResponse(code int) bool {
131139
// not server error
132140
return code < http.StatusInternalServerError
@@ -234,12 +242,3 @@ func wrapStatusCode(code int) string {
234242

235243
return logx.WithColorPadding(strconv.Itoa(code), colour)
236244
}
237-
238-
func getSlowThreshold(r *http.Request) time.Duration {
239-
threshold := slowThreshold.Load()
240-
if r.Header.Get(headerAccept) == valueSSE {
241-
threshold = sseSlowThreshold.Load()
242-
}
243-
244-
return threshold
245-
}

0 commit comments

Comments
 (0)