chore: simplify tests with logtest (#3184)

This commit is contained in:
Kevin Wan
2023-04-29 20:36:29 +08:00
committed by GitHub
parent c0f8a58ed7
commit 14caf5c799
24 changed files with 223 additions and 315 deletions

View File

@@ -31,14 +31,14 @@ const (
// Notice: even if canceled in server side, 499 will be logged as well.
func TimeoutHandler(duration time.Duration) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
if duration > 0 {
return &timeoutHandler{
handler: next,
dt: duration,
}
if duration <= 0 {
return next
}
return next
return &timeoutHandler{
handler: next,
dt: duration,
}
}
}
@@ -207,9 +207,11 @@ func relevantCaller() runtime.Frame {
if !strings.HasPrefix(frame.Function, "net/http.") {
return frame
}
if !more {
break
}
}
return frame
}