package main import ( "embed" "github.com/gin-gonic/gin" "github.com/joho/godotenv" "log" "net/http" "template/migration" "time" ) //go:embed db/dev/*.sql var devMigrations embed.FS func init() { godotenv.Load() log.SetPrefix("") log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile) } func main() { client, err := connectToDb() if err != nil { log.Fatalf("couldn't connect to db: %v", err) } if err := migration.InitializeMigrations(client, devMigrations); err != nil { log.Fatalf("couldn't execute migrations: %v", err) } g := gin.Default() g.NoRoute(func(c *gin.Context) { c.JSON(http.StatusNotFound, gin.H{"message": "no action on given url", "created": time.Now()}) }) g.NoMethod(func(c *gin.Context) { c.JSON(http.StatusMethodNotAllowed, gin.H{"message": "no action on given method", "created": time.Now()}) }) g.GET("/", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"message": "hello world", "created": time.Now()}) }) log.Fatal(http.ListenAndServe(":5281", g)) }