mirror of
https://github.com/rjNemo/go-microservices-tuto
synced 2026-06-06 02:16:46 +00:00
17 lines
374 B
Go
17 lines
374 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
// New creates a server using given mux and port
|
|
func New(mux http.Handler, port string) *http.Server {
|
|
return &http.Server{
|
|
Addr: port,
|
|
Handler: mux,
|
|
ReadTimeout: 5 * time.Second,
|
|
WriteTimeout: 10 * time.Second,
|
|
IdleTimeout: 120 * time.Second, // keep connection opened to prevent Ddos attacks
|
|
}
|
|
}
|