summaryrefslogtreecommitdiffstats
path: root/bridge/api/api.go
diff options
context:
space:
mode:
authorDuco van Amstel <duco.vanamstel@gmail.com>2018-11-15 19:43:43 +0000
committerWim <wim@42.be>2018-11-15 20:43:43 +0100
commitce21ba154585395e792c059ac156299071405247 (patch)
treef76f4617cc2c099a9a2e97bc85fce28cf04010b1 /bridge/api/api.go
parentc89085bf44333b4decd75e30cec5849dca859938 (diff)
downloadmatterbridge-msglm-ce21ba154585395e792c059ac156299071405247.tar.gz
matterbridge-msglm-ce21ba154585395e792c059ac156299071405247.tar.bz2
matterbridge-msglm-ce21ba154585395e792c059ac156299071405247.zip
Fix golint linter issues and enable it in CI (#593)
Diffstat (limited to 'bridge/api/api.go')
-rw-r--r--bridge/api/api.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/bridge/api/api.go b/bridge/api/api.go
index eef41a4a..f8a7c04c 100644
--- a/bridge/api/api.go
+++ b/bridge/api/api.go
@@ -13,13 +13,13 @@ import (
"github.com/zfjagann/golang-ring"
)
-type Api struct {
+type API struct {
Messages ring.Ring
sync.RWMutex
*bridge.Config
}
-type ApiMessage struct {
+type Message struct {
Text string `json:"text"`
Username string `json:"username"`
UserID string `json:"userid"`
@@ -28,7 +28,7 @@ type ApiMessage struct {
}
func New(cfg *bridge.Config) bridge.Bridger {
- b := &Api{Config: cfg}
+ b := &API{Config: cfg}
e := echo.New()
e.HideBanner = true
e.HidePort = true
@@ -55,34 +55,34 @@ func New(cfg *bridge.Config) bridge.Bridger {
return b
}
-func (b *Api) Connect() error {
+func (b *API) Connect() error {
return nil
}
-func (b *Api) Disconnect() error {
+func (b *API) Disconnect() error {
return nil
}
-func (b *Api) JoinChannel(channel config.ChannelInfo) error {
+func (b *API) JoinChannel(channel config.ChannelInfo) error {
return nil
}
-func (b *Api) Send(msg config.Message) (string, error) {
+func (b *API) Send(msg config.Message) (string, error) {
b.Lock()
defer b.Unlock()
// ignore delete messages
- if msg.Event == config.EVENT_MSG_DELETE {
+ if msg.Event == config.EventMsgDelete {
return "", nil
}
b.Messages.Enqueue(&msg)
return "", nil
}
-func (b *Api) handleHealthcheck(c echo.Context) error {
+func (b *API) handleHealthcheck(c echo.Context) error {
return c.String(http.StatusOK, "OK")
}
-func (b *Api) handlePostMessage(c echo.Context) error {
+func (b *API) handlePostMessage(c echo.Context) error {
message := config.Message{}
if err := c.Bind(&message); err != nil {
return err
@@ -98,7 +98,7 @@ func (b *Api) handlePostMessage(c echo.Context) error {
return c.JSON(http.StatusOK, message)
}
-func (b *Api) handleMessages(c echo.Context) error {
+func (b *API) handleMessages(c echo.Context) error {
b.Lock()
defer b.Unlock()
c.JSONPretty(http.StatusOK, b.Messages.Values(), " ")
@@ -106,11 +106,11 @@ func (b *Api) handleMessages(c echo.Context) error {
return nil
}
-func (b *Api) handleStream(c echo.Context) error {
+func (b *API) handleStream(c echo.Context) error {
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSON)
c.Response().WriteHeader(http.StatusOK)
greet := config.Message{
- Event: config.EVENT_API_CONNECTED,
+ Event: config.EventAPIConnected,
Timestamp: time.Now(),
}
if err := json.NewEncoder(c.Response()).Encode(greet); err != nil {