summaryrefslogtreecommitdiff
path: root/pkg/srv/srv.go
blob: a2be3635f33471283a3404035ced5e3abef0af9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package srv

import (
	"log"
	"net/http"
	"time"
)

func New(cfg *Config) *http.Server {
	return &http.Server{
		Addr:              cfg.BindAddress,
		Handler:           cfg.Mux,
		TLSConfig:         cfg.TLS,
		ReadHeaderTimeout: 10 * time.Second,
		ReadTimeout:       30 * time.Second,
		WriteTimeout:      2 * time.Minute,
		IdleTimeout:       5 * time.Minute,
		ErrorLog:          log.Default(),
	}
}

func Run(c *Config) error {
	return c.Run(New(c))
}