mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-24 19:52:03 -08:00
Add ReadTimeout to close lingering connections (mattermost). See #125
This commit is contained in:
parent
386fa58b67
commit
8b286fb009
@ -12,6 +12,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// OMessage for mattermost incoming webhook. (send to mattermost)
|
// OMessage for mattermost incoming webhook. (send to mattermost)
|
||||||
@ -82,8 +83,14 @@ func New(url string, config Config) *Client {
|
|||||||
func (c *Client) StartServer() {
|
func (c *Client) StartServer() {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.Handle("/", c)
|
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)
|
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)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user