mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
32 lines
514 B
Go
32 lines
514 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gotest/internal"
|
|
"github.com/joho/godotenv"
|
|
)
|
|
|
|
func initEnvVariables() {
|
|
if godotenv.Load() != nil {
|
|
panic("Error loading .env file.")
|
|
}
|
|
}
|
|
|
|
func initGin() {
|
|
r := gin.Default()
|
|
r.SetTrustedProxies([]string{"localhost"})
|
|
|
|
r.GET("/ping", internal.Ping)
|
|
r.GET("/get-all-articles", internal.GetAllArticles)
|
|
r.POST("/add-article", internal.AddArticle)
|
|
|
|
r.Run(":" + os.Getenv("API_PORT"))
|
|
}
|
|
|
|
func main() {
|
|
initEnvVariables()
|
|
initGin()
|
|
}
|