Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit f7a245186f59a8598163a3d5d38380e2fd810ce2 Author: Wim <wim@42.be> Date: Tue Feb 21 22:13:34 2017 +0000 Add ReadTimeout to close lingering connections (mattermost). See #125 diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go index 0880884..7d02ef4 100644 --- a/matterhook/matterhook.go +++ b/matterhook/matterhook.go @@ -126 +127 @@ import (   "log"   "net"   "net/http" + "time"  )    // OMessage for mattermost incoming webhook. (send to mattermost) @@ -828 +8314 @@ 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)   }  }