mirror of
https://github.com/wahyd4/push.git
synced 2026-08-08 21:03:06 +10:00
32 lines
529 B
Go
32 lines
529 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io/ioutil"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/wahyd4/push/messages"
|
|
)
|
|
|
|
func main() {
|
|
r := gin.Default()
|
|
r.GET("/ping", func(c *gin.Context) {
|
|
c.JSON(200, gin.H{
|
|
"message": "pong",
|
|
})
|
|
})
|
|
|
|
r.POST("/api/push", func(c *gin.Context) {
|
|
msg := messages.ActionMessage{}
|
|
bytes, err := ioutil.ReadAll(c.Request.Body)
|
|
if err != nil {
|
|
logrus.Errorf(err.Error())
|
|
}
|
|
fmt.Println(string(bytes))
|
|
_ = c.BindJSON(&msg)
|
|
logrus.Info(msg)
|
|
})
|
|
r.Run()
|
|
}
|