graphicek/server/routes/sensors.go

22 lines
327 B
Go
Raw Normal View History

2022-08-13 23:39:18 +02:00
package routes
2022-08-13 23:33:50 +02:00
import (
2022-08-13 23:39:18 +02:00
"basic-sensor-receiver/app"
2022-08-13 23:33:50 +02:00
"net/http"
"github.com/gin-gonic/gin"
)
2022-08-13 23:39:18 +02:00
func GetSensors(s *app.Server) gin.HandlerFunc {
2022-08-13 23:33:50 +02:00
return func(c *gin.Context) {
sensors, err := s.Services.Sensors.GetList()
if err != nil {
c.AbortWithError(500, err)
return
}
c.JSON(http.StatusOK, sensors)
}
}