Se o gin tivesse usado http.Server
, eu poderia simplesmente ter feito o seguinte:
// s is a http.Server instance
s.SetKeepAlivesEnabled(false)
Mas o gim não permite isso. Então, como podemos fazer isso ?
: +1:
pode ser especialmente útil para servidores REST escaláveis, para que as conexões de solicitação única não demorem.
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) e o servidor HTTP trabalham em diferentes camadas de abstração.
@manucorporat incrível e simples. Obrigado.
Comentários muito úteis
https://github.com/gin-gonic/gin#custom -http-configuration
Gin (muxer) e o servidor HTTP trabalham em diferentes camadas de abstração.