Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to disabe keepalive #280

Closed
oryband opened this issue May 6, 2015 · 4 comments
Closed

add support to disabe keepalive #280

oryband opened this issue May 6, 2015 · 4 comments

Comments

@oryband
Copy link

oryband commented May 6, 2015

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?

@bolshoy
Copy link

bolshoy commented May 6, 2015

👍
could be especially useful for scalable REST servers, so single-request connections don't linger.

@manucorporat
Copy link
Contributor

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.

@oryband
Copy link
Author

oryband commented May 6, 2015

@manucorporat amazing and simple. Thanks.

@palrohitg
Copy link

palrohitg commented Jan 29, 2023

@manucorporat would be great if we you can specify, how to configure the custom timeout in seconds example: it node.js we can specify the keepalive timeout in seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants