HTTP timeout middleware for Go.
go get -u github.com/go-http-utils/timeout
API documentation can be found here: https://godoc.org/github.com/go-http-utils/timeout
import (
"github.com/go-http-utils/timeout"
)
mux := http.NewServeMux()
mux.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
res.Write([]byte("Hello World"))
})
http.ListenAndServe(":8080", timeout.Handler(mux, time.Second*10, timeout.DefaultTimeoutHandler))