package main import ( "net/http" "github.com/flamego/flamego" "github.com/flamego/template" "git.metaunix.net/BitGoblin/colossus/models" ) func main() { // initialize database connection models.InitDB() // start initialize Flamego router f := flamego.Classic() // serve static files from ./public/ f.Use(flamego.Static( flamego.StaticOptions{ Directory: "public", }, )) // initialize template engine f.Use(template.Templater(template.Options{ Directory: "./views", })) // register route handlers f.Get("/", func(t template.Template, data template.Data) { var hardware []models.Component models.DB.Find(&hardware) data["hardware"] = hardware data["title"] = "Dashboard" t.HTML(http.StatusOK, "index") }) f.Get("/hardware/add", func(c flamego.Context) { models.DB.Create(&models.Component{ Name: "PowerColor RX 570 4GB", Manufacturer: "PowerColor", Type: "Graphics Card", }) c.Redirect("/") }) f.Run() }