From ce21ba154585395e792c059ac156299071405247 Mon Sep 17 00:00:00 2001 From: Duco van Amstel Date: Thu, 15 Nov 2018 19:43:43 +0000 Subject: Fix golint linter issues and enable it in CI (#593) --- bridge/api/api.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'bridge/api') 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 { -- cgit v1.2.3