idecnode/pkg/apiv2/message.go

29 lines
516 B
Go
Raw Normal View History

2024-10-29 01:21:05 +03:00
package apiv2
import (
"net/http"
"github.com/labstack/echo/v4"
)
func (a *API) getMessagesHandler(c echo.Context) error {
q := new(getMessagesRequest)
if err := c.Bind(q); err != nil {
return err
}
msgs, err := a.idec.GetMessagesByEcho(q.Echo, q.Message, q.Offset, q.Limit)
if err != nil {
return err
}
return c.JSON(http.StatusOK, msgs)
}
type getMessagesRequest struct {
Echo string `query:"e"`
Message string `query:"m"`
Offset int `query:"offset"`
Limit int `query:"limit"`
}