feat: support customizing timeout for specific route (#1203)

* feat: support customizing timeout for specific route

* test: add more tests
This commit is contained in:
Kevin Wan
2021-11-03 22:20:32 +08:00
committed by GitHub
parent 01786c5e63
commit 3ede597a15
5 changed files with 65 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import (
"log"
"net/http"
"path"
"time"
"github.com/tal-tech/go-zero/core/logx"
"github.com/tal-tech/go-zero/rest/handler"
@@ -204,6 +205,13 @@ func WithSignature(signature SignatureConf) RouteOption {
}
}
// WithTimeout returns a RouteOption to set timeout with given value.
func WithTimeout(timeout time.Duration) RouteOption {
return func(r *featuredRoutes) {
r.timeout = timeout
}
}
// WithTLSConfig returns a RunOption that with given tls config.
func WithTLSConfig(cfg *tls.Config) RunOption {
return func(srv *Server) {