summaryrefslogtreecommitdiffstats
path: root/matterhook
diff options
context:
space:
mode:
authorWim <wim@42.be>2015-10-28 17:18:05 +0100
committerWim <wim@42.be>2015-10-28 17:19:32 +0100
commit90f276863b12cc9b2a2f3275944c285f01a7c04e (patch)
tree0a0517fdf2f55b2d9cab35d78cec71605577e728 /matterhook
parent5282cdaccdb2cbac603ade80eaff168ecfe93641 (diff)
downloadmatterbridge-msglm-90f276863b12cc9b2a2f3275944c285f01a7c04e.tar.gz
matterbridge-msglm-90f276863b12cc9b2a2f3275944c285f01a7c04e.tar.bz2
matterbridge-msglm-90f276863b12cc9b2a2f3275944c285f01a7c04e.zip
Add DisableServer option
Diffstat (limited to 'matterhook')
-rw-r--r--matterhook/matterhook.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/matterhook/matterhook.go b/matterhook/matterhook.go
index 1ff1f428..85335792 100644
--- a/matterhook/matterhook.go
+++ b/matterhook/matterhook.go
@@ -40,7 +40,7 @@ type IMessage struct {
// Client for Mattermost.
type Client struct {
- url string
+ Url string // URL for incoming webhooks on mattermost.
In chan IMessage
Out chan OMessage
httpclient *http.Client
@@ -52,11 +52,12 @@ type Config struct {
Port int // Port to listen on.
Token string // Only allow this token from Mattermost. (Allow everything when empty)
InsecureSkipVerify bool // disable certificate checking
+ DisableServer bool // Do not start server for outgoing webhooks from Mattermost.
}
// New Mattermost client.
func New(url string, config Config) *Client {
- c := &Client{url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
+ c := &Client{Url: url, In: make(chan IMessage), Out: make(chan OMessage), Config: config}
if c.Port == 0 {
c.Port = 9999
}
@@ -64,8 +65,9 @@ func New(url string, config Config) *Client {
TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify},
}
c.httpclient = &http.Client{Transport: tr}
-
- go c.StartServer()
+ if !c.DisableServer {
+ go c.StartServer()
+ }
return c
}
@@ -132,7 +134,7 @@ func (c *Client) Send(msg OMessage) error {
if err != nil {
return err
}
- resp, err := c.httpclient.Post(c.url, "application/json", bytes.NewReader(buf))
+ resp, err := c.httpclient.Post(c.Url, "application/json", bytes.NewReader(buf))
if err != nil {
return err
}