18 lines
390 B
Go
18 lines
390 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// MQTTPing publishes the current timestamp to the configured MQTT topic
|
|
func (h *Handler) MQTTPing(c *gin.Context) {
|
|
ts := time.Now().UTC().Format(time.RFC3339)
|
|
if !h.publishMQTT(c, gin.H{"type": "ping", "timestamp": ts}) {
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, gin.H{"timestamp": ts, "topic": h.mqttTopic()})
|
|
}
|