fix: timeout 0s not working (#4932)

Signed-off-by: kevin <wanjunfeng@gmail.com>
This commit is contained in:
Kevin Wan
2025-07-01 17:01:24 +08:00
committed by GitHub
parent 410f56e73a
commit 75cebb65f8
5 changed files with 124 additions and 25 deletions

View File

@@ -283,14 +283,14 @@ func WithSignature(signature SignatureConf) RouteOption {
func WithSSE() RouteOption {
return func(r *featuredRoutes) {
r.sse = true
r.timeout = 0
r.timeout = ptrOfDuration(0)
}
}
// WithTimeout returns a RouteOption to set timeout with given value.
func WithTimeout(timeout time.Duration) RouteOption {
return func(r *featuredRoutes) {
r.timeout = timeout
r.timeout = &timeout
}
}
@@ -325,6 +325,10 @@ func handleError(err error) {
panic(err)
}
func ptrOfDuration(d time.Duration) *time.Duration {
return &d
}
func validateSecret(secret string) {
if len(secret) < 8 {
panic("secret's length can't be less than 8")