0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-01-20 22:52:51 -05:00

server: add idle timeout in http server configuration

This commit is contained in:
Shivam Mishra 2021-04-22 12:18:33 -07:00 committed by Ramkumar Chinchani
parent e73aed99be
commit 3c88102870

View file

@ -8,6 +8,7 @@ import (
"net"
"net/http"
"os"
"time"
"github.com/anuvu/zot/errors"
ext "github.com/anuvu/zot/pkg/extensions"
@ -17,6 +18,10 @@ import (
"github.com/gorilla/mux"
)
const (
idleTimeout = 120 * time.Second
)
type Controller struct {
Config *Config
Router *mux.Router
@ -60,7 +65,11 @@ func (c *Controller) Run() error {
_ = NewRouteHandler(c)
addr := fmt.Sprintf("%s:%s", c.Config.HTTP.Address, c.Config.HTTP.Port)
server := &http.Server{Addr: addr, Handler: c.Router}
server := &http.Server{
Addr: addr,
Handler: c.Router,
IdleTimeout: idleTimeout,
}
c.Server = server
// Create the listener