add WriteTimeout

This commit is contained in:
Livio Spring 2024-12-04 08:13:26 +01:00
parent 498542c983
commit ccab1a346a
No known key found for this signature in database
GPG Key ID: 26BB1C2FA5952CF0

View File

@ -559,13 +559,14 @@ func startAPIs(
} }
type test struct { type test struct {
IdleTimeout time.Duration IdleTimeout time.Duration
ReadTimeout time.Duration ReadTimeout time.Duration
WriteTimeout time.Duration
} }
func listen(ctx context.Context, router *mux.Router, port uint16, tlsConfig *tls.Config, shutdown <-chan os.Signal, test test) error { func listen(ctx context.Context, router *mux.Router, port uint16, tlsConfig *tls.Config, shutdown <-chan os.Signal, test test) error {
http2Server := &http2.Server{IdleTimeout: test.IdleTimeout} http2Server := &http2.Server{IdleTimeout: test.IdleTimeout}
http1Server := &http.Server{Handler: h2c.NewHandler(router, http2Server), TLSConfig: tlsConfig, ReadTimeout: test.ReadTimeout, IdleTimeout: test.IdleTimeout} http1Server := &http.Server{Handler: h2c.NewHandler(router, http2Server), TLSConfig: tlsConfig, ReadTimeout: test.ReadTimeout, IdleTimeout: test.IdleTimeout, WriteTimeout: test.WriteTimeout}
lc := net.ListenConfig() lc := net.ListenConfig()
lis, err := lc.Listen(ctx, "tcp", fmt.Sprintf(":%d", port)) lis, err := lc.Listen(ctx, "tcp", fmt.Sprintf(":%d", port))