mirror of
https://github.com/tobiasehlert/teslamateapi.git
synced 2026-02-27 09:54:18 +08:00
implementation of versioning in uri
updating README with version info
This commit is contained in:
@@ -113,15 +113,16 @@ Basically the same environment variables for the database, mqqt and timezone nee
|
||||
More detailed documentation of every endpoint will come..
|
||||
|
||||
- GET `/`
|
||||
- GET `/cars`
|
||||
- GET `/cars/:CarID`
|
||||
- GET `/cars/:CarID/charges`
|
||||
- GET `/cars/:CarID/charges/:ChargeID`
|
||||
- GET `/cars/:CarID/drives`
|
||||
- GET `/cars/:CarID/drives/:DriveID`
|
||||
- GET `/cars/:CarID/status`
|
||||
- GET `/cars/:CarID/updates`
|
||||
- GET `/globalsettings`
|
||||
- GET `/v1`
|
||||
- GET `/v1/cars`
|
||||
- GET `/v1/cars/:CarID`
|
||||
- GET `/v1/cars/:CarID/charges`
|
||||
- GET `/v1/cars/:CarID/charges/:ChargeID`
|
||||
- GET `/v1/cars/:CarID/drives`
|
||||
- GET `/v1/cars/:CarID/drives/:DriveID`
|
||||
- GET `/v1/cars/:CarID/status`
|
||||
- GET `/v1/cars/:CarID/updates`
|
||||
- GET `/v1/globalsettings`
|
||||
- GET `/ping`
|
||||
|
||||
## Security information
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// TeslaMateAPICarsChargesDetails func
|
||||
func TeslaMateAPICarsChargesDetails(c *gin.Context) {
|
||||
// TeslaMateAPICarsChargesDetailsV1 func
|
||||
func TeslaMateAPICarsChargesDetailsV1(c *gin.Context) {
|
||||
|
||||
// getting CarID and ChargeID param from URL
|
||||
CarID := convertStringToInteger(c.Param("CarID"))
|
||||
@@ -318,17 +318,17 @@ func TeslaMateAPICarsChargesDetails(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsChargesDetails returned /cars/%d/charges/%d data:", CarID, ChargeID)
|
||||
log.Printf("[debug] TeslaMateAPICarsChargesDetailsV1 returned /cars/%d/charges/%d data:", CarID, ChargeID)
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsChargesDetails executed /cars/%d/charges/%d successful.", CarID, ChargeID)
|
||||
log.Printf("[info] TeslaMateAPICarsChargesDetailsV1 executed /cars/%d/charges/%d successful.", CarID, ChargeID)
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsChargesDetails error in /cars/%d/charges/%d execution!", CarID, ChargeID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsChargesDetails.."})
|
||||
log.Printf("[error] TeslaMateAPICarsChargesDetailsV1 error in /cars/%d/charges/%d execution!", CarID, ChargeID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsChargesDetailsV1.."})
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// TeslaMateAPICars func
|
||||
func TeslaMateAPICars(c *gin.Context) {
|
||||
// TeslaMateAPICarsV1 func
|
||||
func TeslaMateAPICarsV1(c *gin.Context) {
|
||||
|
||||
// getting CarID param from URL
|
||||
ParamCarID := c.Param("CarID")
|
||||
@@ -179,9 +179,9 @@ func TeslaMateAPICars(c *gin.Context) {
|
||||
// print to log about request
|
||||
if gin.IsDebugging() && ValidResponse {
|
||||
if CarID > 0 {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICars returned /cars/%d data:", CarID)
|
||||
log.Printf("[debug] TeslaMateAPICarsV1 returned /cars/%d data:", CarID)
|
||||
} else {
|
||||
log.Println("[TeslaMateApi] TeslaMateAPICars returned /cars data:")
|
||||
log.Println("[debug] TeslaMateAPICarsV1 returned /cars data:")
|
||||
}
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
@@ -190,20 +190,20 @@ func TeslaMateAPICars(c *gin.Context) {
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
if CarID > 0 {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICars executed /cars/%d successful.", CarID)
|
||||
log.Printf("[info] TeslaMateAPICarsV1 executed /cars/%d successful.", CarID)
|
||||
} else {
|
||||
log.Println("[TeslaMateApi] TeslaMateAPICars executed /cars successful.")
|
||||
log.Println("[info] TeslaMateAPICarsV1 executed /cars successful.")
|
||||
}
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
if CarID > 0 {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICars error in /cars/%d execution!", CarID)
|
||||
log.Printf("[error] TeslaMateAPICarsV1 error in /cars/%d execution!", CarID)
|
||||
} else if len(ParamCarID) > 0 {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICars error in /cars/%s execution!", ParamCarID)
|
||||
log.Printf("[error] TeslaMateAPICarsV1 error in /cars/%s execution!", ParamCarID)
|
||||
} else {
|
||||
log.Println("[TeslaMateApi] TeslaMateAPICars error in /cars execution!")
|
||||
log.Println("[error] TeslaMateAPICarsV1 error in /cars execution!")
|
||||
}
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICars.."})
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsV1.."})
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// TeslaMateAPICarsCharges func
|
||||
func TeslaMateAPICarsCharges(c *gin.Context) {
|
||||
// TeslaMateAPICarsChargesV1 func
|
||||
func TeslaMateAPICarsChargesV1(c *gin.Context) {
|
||||
|
||||
// getting CarID param from URL
|
||||
CarID := convertStringToInteger(c.Param("CarID"))
|
||||
@@ -198,17 +198,17 @@ func TeslaMateAPICarsCharges(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsCharges returned /cars/%d/charges data:", CarID)
|
||||
log.Printf("[debug] TeslaMateAPICarsChargesV1 returned /cars/%d/charges data:", CarID)
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsCharges executed /cars/%d/charges successful.", CarID)
|
||||
log.Printf("[info] TeslaMateAPICarsChargesV1 executed /cars/%d/charges successful.", CarID)
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsCharges error in /cars/%d/charges execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsCharges.."})
|
||||
log.Printf("[error] TeslaMateAPICarsChargesV1 error in /cars/%d/charges execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsChargesV1.."})
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// TeslaMateAPICarsDrives func
|
||||
func TeslaMateAPICarsDrives(c *gin.Context) {
|
||||
// TeslaMateAPICarsDrivesV1 func
|
||||
func TeslaMateAPICarsDrivesV1(c *gin.Context) {
|
||||
|
||||
// getting CarID param from URL
|
||||
CarID := convertStringToInteger(c.Param("CarID"))
|
||||
@@ -246,17 +246,17 @@ func TeslaMateAPICarsDrives(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsDrives returned /cars/%d/drives data:", CarID)
|
||||
log.Printf("[debug] TeslaMateAPICarsDrivesV1 returned /cars/%d/drives data:", CarID)
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsDrives executed /cars/%d/drives successful.", CarID)
|
||||
log.Printf("[info] TeslaMateAPICarsDrivesV1 executed /cars/%d/drives successful.", CarID)
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsDrives error in /cars/%d/drives execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsDrives.."})
|
||||
log.Printf("[error] TeslaMateAPICarsDrivesV1 error in /cars/%d/drives execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsDrivesV1.."})
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// TeslaMateAPICarsDrivesDetails func
|
||||
func TeslaMateAPICarsDrivesDetails(c *gin.Context) {
|
||||
// TeslaMateAPICarsDrivesDetailsV1 func
|
||||
func TeslaMateAPICarsDrivesDetailsV1(c *gin.Context) {
|
||||
|
||||
// getting CarID and DriveID param from URL
|
||||
CarID := convertStringToInteger(c.Param("CarID"))
|
||||
@@ -381,17 +381,17 @@ func TeslaMateAPICarsDrivesDetails(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsDrivesDetails returned /cars/%d/drives/%d data:", CarID, DriveID)
|
||||
log.Printf("[debug] TeslaMateAPICarsDrivesDetailsV1 returned /cars/%d/drives/%d data:", CarID, DriveID)
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsDrivesDetails executed /cars/%d/drives/%d successful.", CarID, DriveID)
|
||||
log.Printf("[info] TeslaMateAPICarsDrivesDetailsV1 executed /cars/%d/drives/%d successful.", CarID, DriveID)
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsDrivesDetails error in /cars/%d/drives/%d execution!", CarID, DriveID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsDrivesDetails.."})
|
||||
log.Printf("[error] TeslaMateAPICarsDrivesDetailsV1 error in /cars/%d/drives/%d execution!", CarID, DriveID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsDrivesDetailsV1.."})
|
||||
}
|
||||
}
|
||||
@@ -163,18 +163,18 @@ var f mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
|
||||
} else if MqttTopic == "time_to_full_charge" {
|
||||
MQTTDataTimeToFullCharge = convertStringToFloat(string(msg.Payload()))
|
||||
} else {
|
||||
log.Printf("Error: extraction of data for %s not implemented in mqtt.MessageHandler yet.", MqttTopic)
|
||||
log.Printf("[warning] mqtt.MessageHandler issue.. extraction of data for %s not implemented!", MqttTopic)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TeslaMateAPICarsStatus func
|
||||
func TeslaMateAPICarsStatus(c *gin.Context) {
|
||||
// TeslaMateAPICarsStatusV1 func
|
||||
func TeslaMateAPICarsStatusV1(c *gin.Context) {
|
||||
|
||||
// getting mqtt flag
|
||||
mqttdisabled := getEnvAsBool("DISABLE_MQTT", false)
|
||||
if mqttdisabled {
|
||||
log.Println("[TeslaMateAPICars] DISABLE_MQTT is set to true.. can not return status for car without mqtt!")
|
||||
log.Println("[notice] TeslaMateAPICarsStatusV1 DISABLE_MQTT is set to true.. can not return status for car without mqtt!")
|
||||
c.JSON(http.StatusNotImplemented, gin.H{"error": "mqtt disabled.. status not accessible!"})
|
||||
return
|
||||
}
|
||||
@@ -243,7 +243,7 @@ func TeslaMateAPICarsStatus(c *gin.Context) {
|
||||
|
||||
// showing mqtt successfully connected
|
||||
if gin.IsDebugging() {
|
||||
log.Println("[TeslaMateApi] TeslaMateAPICarsStatus successfully connected to mqtt.")
|
||||
log.Println("TeslaMateAPICarsStatus successfully connected to mqtt.")
|
||||
}
|
||||
|
||||
// creating structs for /cars
|
||||
@@ -548,17 +548,17 @@ func TeslaMateAPICarsStatus(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsStatus returned /cars/%d/status data:", CarID)
|
||||
log.Printf("[debug] TeslaMateAPICarsStatusV1 returned /cars/%d/status data:", CarID)
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsStatus executed /cars/%d/status successful.", CarID)
|
||||
log.Printf("[info] TeslaMateAPICarsStatusV1 executed /cars/%d/status successful.", CarID)
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsStatus error in /cars/%d/status execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsStatus.."})
|
||||
log.Printf("[error] TeslaMateAPICarsStatusV1 error in /cars/%d/status execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsStatusV1.."})
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// TeslaMateAPICarsUpdates func
|
||||
func TeslaMateAPICarsUpdates(c *gin.Context) {
|
||||
// TeslaMateAPICarsUpdatesV1 func
|
||||
func TeslaMateAPICarsUpdatesV1(c *gin.Context) {
|
||||
|
||||
// getting CarID param from URL
|
||||
CarID := convertStringToInteger(c.Param("CarID"))
|
||||
@@ -124,17 +124,17 @@ func TeslaMateAPICarsUpdates(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsUpdates returned /cars/%d/updates data:", CarID)
|
||||
log.Printf("[debug] TeslaMateAPICarsUpdatesV1 returned /cars/%d/updates data:", CarID)
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsUpdates executed /cars/%d/updates successful.", CarID)
|
||||
log.Printf("[info] TeslaMateAPICarsUpdatesV1 executed /cars/%d/updates successful.", CarID)
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Printf("[TeslaMateApi] TeslaMateAPICarsUpdates error in /cars/%d/updates execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsUpdates.."})
|
||||
log.Printf("[error] TeslaMateAPICarsUpdatesV1 error in /cars/%d/updates execution!", CarID)
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPICarsUpdatesV1.."})
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
// TeslaMateAPIGlobalsettings func
|
||||
func TeslaMateAPIGlobalsettings(c *gin.Context) {
|
||||
// TeslaMateAPIGlobalsettingsV1 func
|
||||
func TeslaMateAPIGlobalsettingsV1(c *gin.Context) {
|
||||
|
||||
// creating structs for /globalsettings
|
||||
// AccountInfo struct - child of GlobalSettings
|
||||
@@ -127,17 +127,17 @@ func TeslaMateAPIGlobalsettings(c *gin.Context) {
|
||||
|
||||
// print to log about request
|
||||
if gin.IsDebugging() {
|
||||
log.Println("[TeslaMateApi] TeslaMateAPIGlobalsettings returned /cars data:")
|
||||
log.Println("[debug] TeslaMateAPIGlobalsettingsV1 returned /cars data:")
|
||||
js, _ := json.Marshal(jsonData)
|
||||
log.Printf("%s\n", js)
|
||||
}
|
||||
|
||||
// return jsonData
|
||||
if ValidResponse {
|
||||
log.Println("[TeslaMateApi] TeslaMateAPIGlobalsettings executed /cars successful.")
|
||||
log.Println("[info] TeslaMateAPIGlobalsettingsV1 executed /cars successful.")
|
||||
c.JSON(http.StatusOK, jsonData)
|
||||
} else {
|
||||
log.Println("[TeslaMateApi] TeslaMateAPIGlobalsettings error in /cars execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPIGlobalsettings.."})
|
||||
log.Println("[error] TeslaMateAPIGlobalsettingsV1 error in /cars execution!")
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "something went wrong in TeslaMateAPIGlobalsettingsV1.."})
|
||||
}
|
||||
}
|
||||
+27
-20
@@ -35,29 +35,36 @@ func main() {
|
||||
r := gin.Default()
|
||||
|
||||
// root endpoint telling API is running
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "TeslaMateApi runnnig..",
|
||||
})
|
||||
})
|
||||
r.GET("/", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"message": "TeslaMateApi container runnnig.."}) })
|
||||
|
||||
// TeslaMateApi endpoints
|
||||
r.GET("/cars", TeslaMateAPICars)
|
||||
r.GET("/cars/:CarID", TeslaMateAPICars)
|
||||
r.GET("/cars/:CarID/charges", TeslaMateAPICarsCharges)
|
||||
r.GET("/cars/:CarID/charges/:ChargeID", TeslaMateAPICarsChargesDetails)
|
||||
r.GET("/cars/:CarID/drives", TeslaMateAPICarsDrives)
|
||||
r.GET("/cars/:CarID/drives/:DriveID", TeslaMateAPICarsDrivesDetails)
|
||||
r.GET("/cars/:CarID/status", TeslaMateAPICarsStatus)
|
||||
r.GET("/cars/:CarID/updates", TeslaMateAPICarsUpdates)
|
||||
r.GET("/globalsettings", TeslaMateAPIGlobalsettings)
|
||||
// TeslaMateApi v1 endpoints
|
||||
v1 := r.Group("/v1")
|
||||
{
|
||||
v1.GET("/", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"message": "TeslaMateApi v1 runnnig.."}) })
|
||||
v1.GET("/cars", TeslaMateAPICarsV1)
|
||||
v1.GET("/cars/:CarID", TeslaMateAPICarsV1)
|
||||
v1.GET("/cars/:CarID/charges", TeslaMateAPICarsChargesV1)
|
||||
v1.GET("/cars/:CarID/charges/:ChargeID", TeslaMateAPICarsChargesDetailsV1)
|
||||
v1.GET("/cars/:CarID/drives", TeslaMateAPICarsDrivesV1)
|
||||
v1.GET("/cars/:CarID/drives/:DriveID", TeslaMateAPICarsDrivesDetailsV1)
|
||||
v1.GET("/cars/:CarID/status", TeslaMateAPICarsStatusV1)
|
||||
v1.GET("/cars/:CarID/updates", TeslaMateAPICarsUpdatesV1)
|
||||
v1.GET("/globalsettings", TeslaMateAPIGlobalsettingsV1)
|
||||
}
|
||||
|
||||
// TeslaMateApi endpoints (bofore versioning)
|
||||
r.GET("/cars", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/cars/:CarID", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/cars/:CarID/charges", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/cars/:CarID/charges/:ChargeID", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/cars/:CarID/drives", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/cars/:CarID/drives/:DriveID", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/cars/:CarID/status", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/cars/:CarID/updates", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
r.GET("/globalsettings", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "/v1"+c.Request.RequestURI) })
|
||||
|
||||
// /ping endpoint
|
||||
r.GET("/ping", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "pong",
|
||||
})
|
||||
})
|
||||
r.GET("/ping", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"message": "pong"}) })
|
||||
|
||||
// run this and serve on 0.0.0.0:8080
|
||||
r.Run(":8080")
|
||||
|
||||
Reference in New Issue
Block a user