refactor: guard timeout on API files (#1726)

This commit is contained in:
Kevin Wan
2022-03-31 21:39:02 +08:00
committed by GitHub
parent 321dc2d410
commit 2b9fc26c38
5 changed files with 44 additions and 31 deletions

View File

@@ -119,6 +119,14 @@ func (ng *engine) bindRoutes(router httpx.Router) error {
return nil
}
func (ng *engine) checkedMaxBytes(bytes int64) int64 {
if bytes > 0 {
return bytes
}
return ng.conf.MaxBytes
}
func (ng *engine) checkedTimeout(timeout time.Duration) time.Duration {
if timeout > 0 {
return timeout
@@ -127,15 +135,6 @@ func (ng *engine) checkedTimeout(timeout time.Duration) time.Duration {
return time.Duration(ng.conf.Timeout) * time.Millisecond
}
func (ng *engine) checkedMaxBytes(bytes int64) int64 {
if bytes > 0 {
return bytes
}
return ng.conf.MaxBytes
}
func (ng *engine) createMetrics() *stat.Metrics {
var metrics *stat.Metrics