diff options
author | Wim <wim@42.be> | 2017-12-19 23:15:03 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-12-19 23:15:03 +0100 |
commit | 265457b45171dcae96a1aac9454e3bda2cd0557a (patch) | |
tree | 35342a6b83e01b708b20442378799c7692fdf519 /bridge/api | |
parent | 4a4a29c9f6fe202cf4379c0df2ba313848bb8d11 (diff) | |
download | matterbridge-msglm-265457b45171dcae96a1aac9454e3bda2cd0557a.tar.gz matterbridge-msglm-265457b45171dcae96a1aac9454e3bda2cd0557a.tar.bz2 matterbridge-msglm-265457b45171dcae96a1aac9454e3bda2cd0557a.zip |
Refactor and add MediaDownloadSize to General
Diffstat (limited to 'bridge/api')
-rw-r--r-- | bridge/api/api.go | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/bridge/api/api.go b/bridge/api/api.go index 8bae1281..45bc11d3 100644 --- a/bridge/api/api.go +++ b/bridge/api/api.go @@ -13,11 +13,9 @@ import ( ) type Api struct { - Config *config.Protocol - Remote chan config.Message - Account string Messages ring.Ring sync.RWMutex + *config.BridgeConfig } type ApiMessage struct { @@ -35,14 +33,11 @@ func init() { flog = log.WithFields(log.Fields{"module": protocol}) } -func New(cfg config.Protocol, account string, c chan config.Message) *Api { - b := &Api{} +func New(cfg *config.BridgeConfig) *Api { + b := &Api{BridgeConfig: cfg} e := echo.New() b.Messages = ring.Ring{} - b.Messages.SetCapacity(cfg.Buffer) - b.Config = &cfg - b.Account = account - b.Remote = c + b.Messages.SetCapacity(b.Config.Buffer) if b.Config.Token != "" { e.Use(middleware.KeyAuth(func(key string, c echo.Context) (bool, error) { return key == b.Config.Token, nil @@ -52,7 +47,7 @@ func New(cfg config.Protocol, account string, c chan config.Message) *Api { e.GET("/api/stream", b.handleStream) e.POST("/api/message", b.handlePostMessage) go func() { - flog.Fatal(e.Start(cfg.BindAddress)) + flog.Fatal(e.Start(b.Config.BindAddress)) }() return b } |