diff --git a/internal/server/http.go b/internal/server/http.go index f48829f..bbe4544 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -14,6 +14,7 @@ import ( "github.com/go-kratos/kratos/v2/transport/http/pprof" "github.com/gorilla/handlers" http2 "net/http" + "time" v1 "voucher/api/v1" "voucher/internal/conf" log2 "voucher/internal/pkg/log" @@ -50,8 +51,9 @@ func buildHTTPServer(c *conf.Bootstrap, accessLogger *log2.AccessLogger, log *lo if c.Server.Http.Addr != "" { opts = append(opts, http.Address(c.Server.Http.Addr)) } + if c.Server.Http.Timeout != nil { - opts = append(opts, http.Timeout(c.Server.Http.Timeout.AsDuration())) + opts = append(opts, http.Timeout(30*time.Second)) } // 允许跨域