Convenience functions and wrappers around net
and net/http
for ...
- Timeouts
- Graceful Server Shutdowns with Connection Draining
- Healthy and Ready handlers
package main
import (
"net/http"
"github.com/mattes/go-net/server"
)
func main() {
server.IsBehindGoogleLoadBalancer() // optional
mux := http.NewServeMux()
// add handlers ...
// Creates a new Server with /health and /ready handlers
// which gracefully shuts down on SIGINT or SIGTERM
log.Fatal(server.ListenAndServe(":8080", mux))
}
Health | Ready | |
---|---|---|
Running | 200 | 200 |
Shutting down | 200 | 503 |