diff options
author | Wim <wim@42.be> | 2017-02-21 22:13:34 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-02-21 22:13:34 +0100 |
commit | 8b286fb009c26325268d4b838b3b83413af83f11 (patch) | |
tree | 7301ff71909c9be9a5f3376b843743d6e553370f /matterhook/matterhook.go | |
parent | 386fa58b6764fddffa0e902ac8359a5ae93053e0 (diff) | |
download | matterbridge-msglm-8b286fb009c26325268d4b838b3b83413af83f11.tar.gz matterbridge-msglm-8b286fb009c26325268d4b838b3b83413af83f11.tar.bz2 matterbridge-msglm-8b286fb009c26325268d4b838b3b83413af83f11.zip |
Add ReadTimeout to close lingering connections (mattermost). See #125
Diffstat (limited to 'matterhook/matterhook.go')
-rw-r--r-- | matterhook/matterhook.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go index 0880884b..7d02ef4d 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -12,6 +12,7 @@ import ( "log" "net" "net/http" + "time" ) // OMessage for mattermost incoming webhook. (send to mattermost) @@ -82,8 +83,14 @@ func New(url string, config Config) *Client { func (c *Client) StartServer() { mux := http.NewServeMux() mux.Handle("/", c) + srv := &http.Server{ + ReadTimeout: 5 * time.Second, + WriteTimeout: 10 * time.Second, + Handler: mux, + Addr: c.BindAddress, + } log.Printf("Listening on http://%v...\n", c.BindAddress) - if err := http.ListenAndServe(c.BindAddress, mux); err != nil { + if err := srv.ListenAndServe(); err != nil { log.Fatal(err) } } |