If gin would've used http.Server
, I could've just done the following:
// s is a http.Server instance
s.SetKeepAlivesEnabled(false)
But gin doesn't allow that. So, how do we accomplish this?
:+1:
could be especially useful for scalable REST servers, so single-request connections don't linger.
https://github.com/gin-gonic/gin#custom-http-configuration
router := gin.Default()
s := &http.Server{
Addr: ":8080",
Handler: router, // < here Gin is attached to the HTTP server
// ReadTimeout: 10 * time.Second,
// WriteTimeout: 10 * time.Second,
// MaxHeaderBytes: 1 << 20,
}
s.SetKeepAlivesEnabled(false)
s.ListenAndServe()
Gin (muxer) and the HTTP server work at different layers of abstraction.
@manucorporat amazing and simple. Thanks.
Most helpful comment
https://github.com/gin-gonic/gin#custom-http-configuration
Gin (muxer) and the HTTP server work at different layers of abstraction.