2022-05-19 13:47:27 +00:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
jwt "github.com/appleboy/gin-jwt/v2"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c *Controller) HeartBeat(gctx *gin.Context) {
|
|
|
|
|
|
|
|
claims := jwt.ExtractClaims(gctx)
|
2022-10-14 14:12:21 +00:00
|
|
|
// TBD: use defined rather than hardcoded key to find back owner
|
2022-05-19 13:47:27 +00:00
|
|
|
machineID := claims["id"].(string)
|
|
|
|
|
|
|
|
if err := c.DBClient.UpdateMachineLastHeartBeat(machineID); err != nil {
|
|
|
|
c.HandleDBErrors(gctx, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
gctx.Status(http.StatusOK)
|
|
|
|
}
|