Skip to content

Instantly share code, notes, and snippets.

@BK1031
Created July 10, 2024 16:55
Show Gist options
  • Save BK1031/3ee12b530dc49c2dc093fc53e89d4427 to your computer and use it in GitHub Desktop.
Save BK1031/3ee12b530dc49c2dc093fc53e89d4427 to your computer and use it in GitHub Desktop.
racecar_analytics get endpoints
package main
import (
"net/http"
"time"
"github.com/gin-gonic/gin"
)
var Port = "9000"
func StartServer() {
r := gin.Default()
r.GET("/ecu", GetAllECUs)
r.GET("/battery", GetAllBatteries)
r.Run(":" + Port)
}
func GetAllECUs(c *gin.Context) {
var ecus []ECU
DB.Find(&ecus)
c.JSON(http.StatusOK, ecus)
}
func GetAllBatteries(c *gin.Context) {
var batteries []Battery
DB.Find(&batteries)
c.JSON(http.StatusOK, batteries)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment