go-microservices-tuto/server/server.go
2020-07-13 23:21:30 +02:00

17 lines
375 B
Go

package server
import (
"net/http"
"time"
)
// New creates a server using given mux and port
func New(mux *http.ServeMux, port string) *http.Server {
return &http.Server{
Addr: port,
Handler: mux,
IdleTimeout: 120 * time.Second, // keep connection opened to prevent Ddos attacks
ReadTimeout: 1 * time.Second,
WriteTimeout: 1 * time.Second,
}
}