
* add the last_heartbeat field * add heartbeat controller * add endpoint of heartbeat * heartbeat integration * add last_heartbeat to cscli machines list
21 lines
442 B
Go
21 lines
442 B
Go
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)
|
|
/*TBD : use defines rather than hardcoded key to find back owner*/
|
|
machineID := claims["id"].(string)
|
|
|
|
if err := c.DBClient.UpdateMachineLastHeartBeat(machineID); err != nil {
|
|
c.HandleDBErrors(gctx, err)
|
|
return
|
|
}
|
|
gctx.Status(http.StatusOK)
|
|
}
|