From 265457b45171dcae96a1aac9454e3bda2cd0557a Mon Sep 17 00:00:00 2001 From: Wim Date: Tue, 19 Dec 2017 23:15:03 +0100 Subject: Refactor and add MediaDownloadSize to General --- bridge/api/api.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'bridge/api') 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 } -- cgit v1.2.3