summaryrefslogtreecommitdiffstats
path: root/bridge/api/api.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-03-04 23:52:14 +0100
committerWim <wim@42.be>2018-03-04 23:52:14 +0100
commitf2f1d874e1b4f997c111de87121eec98eef66381 (patch)
tree34a44e866c053ef298d5482370208a0bb9dc4738 /bridge/api/api.go
parent25a72113b122f984c904b24c4af23a1cba1eff45 (diff)
downloadmatterbridge-msglm-f2f1d874e1b4f997c111de87121eec98eef66381.tar.gz
matterbridge-msglm-f2f1d874e1b4f997c111de87121eec98eef66381.tar.bz2
matterbridge-msglm-f2f1d874e1b4f997c111de87121eec98eef66381.zip
Use viper (github.com/spf13/viper) for configuration
Diffstat (limited to 'bridge/api/api.go')
-rw-r--r--bridge/api/api.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/bridge/api/api.go b/bridge/api/api.go
index b4415267..54eea4a7 100644
--- a/bridge/api/api.go
+++ b/bridge/api/api.go
@@ -15,7 +15,7 @@ import (
type Api struct {
Messages ring.Ring
sync.RWMutex
- *config.BridgeConfig
+ *bridge.Config
}
type ApiMessage struct {
@@ -26,27 +26,27 @@ type ApiMessage struct {
Gateway string `json:"gateway"`
}
-func New(cfg *config.BridgeConfig) bridge.Bridger {
- b := &Api{BridgeConfig: cfg}
+func New(cfg *bridge.Config) bridge.Bridger {
+ b := &Api{Config: cfg}
e := echo.New()
e.HideBanner = true
e.HidePort = true
b.Messages = ring.Ring{}
- b.Messages.SetCapacity(b.Config.Buffer)
- if b.Config.Token != "" {
+ b.Messages.SetCapacity(b.GetInt("Buffer"))
+ if b.GetString("Token") != "" {
e.Use(middleware.KeyAuth(func(key string, c echo.Context) (bool, error) {
- return key == b.Config.Token, nil
+ return key == b.GetString("Token"), nil
}))
}
e.GET("/api/messages", b.handleMessages)
e.GET("/api/stream", b.handleStream)
e.POST("/api/message", b.handlePostMessage)
go func() {
- if b.Config.BindAddress == "" {
+ if b.GetString("BindAddress") == "" {
b.Log.Fatalf("No BindAddress configured.")
}
- b.Log.Infof("Listening on %s", b.Config.BindAddress)
- b.Log.Fatal(e.Start(b.Config.BindAddress))
+ b.Log.Infof("Listening on %s", b.GetString("BindAddress"))
+ b.Log.Fatal(e.Start(b.GetString("BindAddress")))
}()
return b
}