EnvronmentManagement/Api/main.go

37 lines
560 B
Go
Raw Normal View History

2021-09-28 02:52:04 +01:00
package main
import (
"os"
"51m0n.com/EnvironmentManagerAPI/v2/src"
"github.com/gin-gonic/gin"
)
func main() {
src.DbConnect()
r := gin.Default()
r.Use(gin.Recovery())
initializeRoutes(r)
r.Run(getPort())
src.DbDisconnect()
}
func initializeRoutes(r *gin.Engine) {
2021-10-04 00:56:24 +01:00
r.POST("/data", src.CreateData)
r.PUT("/data/:id", src.CreateEnvironmentData)
2021-10-02 01:43:52 +01:00
r.Use(src.AEADHandler)
{
r.PUT("/data/authed/:id", src.CreateEnvironmentData)
}
2021-09-28 02:52:04 +01:00
}
func getPort() string {
port := os.Getenv("GIN_PORT")
if port == "" {
port = "8080"
}
return ":" + port
}