Endpoint Change, and Can Request Unique ID from System

This commit is contained in:
Supan Adit Pratama 2019-10-31 22:50:30 +07:00
parent e7a3a34114
commit 5c78bf9ddb

10
main.go
View File

@ -5,6 +5,7 @@ import (
"github.com/gin-contrib/sse" "github.com/gin-contrib/sse"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-redis/redis" "github.com/go-redis/redis"
"github.com/rs/xid"
"github.com/supanadit/geosmartsystem/model" "github.com/supanadit/geosmartsystem/model"
"github.com/supanadit/geosmartsystem/model/tile38" "github.com/supanadit/geosmartsystem/model/tile38"
"net/http" "net/http"
@ -16,12 +17,9 @@ func main() {
}) })
r := gin.Default() r := gin.Default()
r.Use(cors.Default()) r.Use(cors.Default())
r.GET("/get/unique/id", func(c *gin.Context) { r.GET("/unique/id", func(c *gin.Context) {
var location model.Location id := xid.New()
_ = c.BindJSON(&location) c.JSON(200, gin.H{"id": id.String()})
c.Writer.Header().Set("Content-Type", "application/json")
client.Do("SET", location.Type, location.Id, "POINT", location.Lat, location.Lng)
c.JSON(200, gin.H{"status": "ok"})
}) })
r.POST("/set/point", func(c *gin.Context) { r.POST("/set/point", func(c *gin.Context) {
var location model.Location var location model.Location