summaryrefslogtreecommitdiff
path: root/pkg/apiv2/message.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/apiv2/message.go')
-rw-r--r--pkg/apiv2/message.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/apiv2/message.go b/pkg/apiv2/message.go
new file mode 100644
index 0000000..7b06fde
--- /dev/null
+++ b/pkg/apiv2/message.go
@@ -0,0 +1,28 @@
+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"`
+}