mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 18:30:02 +08:00
chore: code refactoring (#5204)
This commit is contained in:
@@ -127,6 +127,14 @@ func dumpRequest(r *http.Request) string {
|
|||||||
return string(reqContent)
|
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 {
|
func isOkResponse(code int) bool {
|
||||||
// not server error
|
// not server error
|
||||||
return code < http.StatusInternalServerError
|
return code < http.StatusInternalServerError
|
||||||
@@ -234,12 +242,3 @@ func wrapStatusCode(code int) string {
|
|||||||
|
|
||||||
return logx.WithColorPadding(strconv.Itoa(code), colour)
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user