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:
parent
e73aed99be
commit
3c88102870
1 changed files with 10 additions and 1 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/anuvu/zot/errors"
|
"github.com/anuvu/zot/errors"
|
||||||
ext "github.com/anuvu/zot/pkg/extensions"
|
ext "github.com/anuvu/zot/pkg/extensions"
|
||||||
|
@ -17,6 +18,10 @@ import (
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
idleTimeout = 120 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
type Controller struct {
|
type Controller struct {
|
||||||
Config *Config
|
Config *Config
|
||||||
Router *mux.Router
|
Router *mux.Router
|
||||||
|
@ -60,7 +65,11 @@ func (c *Controller) Run() error {
|
||||||
_ = NewRouteHandler(c)
|
_ = NewRouteHandler(c)
|
||||||
|
|
||||||
addr := fmt.Sprintf("%s:%s", c.Config.HTTP.Address, c.Config.HTTP.Port)
|
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
|
c.Server = server
|
||||||
|
|
||||||
// Create the listener
|
// Create the listener
|
||||||
|
|
Loading…
Add table
Reference in a new issue