blt/main.go

37 lines
727 B
Go

package main
import (
"log"
"net/http"
"github.com/flamego/flamego"
"github.com/flamego/template"
"git.metaunix.net/bitgoblin/blt/models"
"git.metaunix.net/bitgoblin/blt/web"
"git.metaunix.net/bitgoblin/blt/web/middleware"
)
var Version string = "N/a"
func main() {
// initial Flamego server object
f := flamego.Classic()
// initialize database
models.Open()
// initialize templating engine
f.Use(template.Templater())
// inject custom middleware
f.Use(middleware.CustomVars)
// register routes to server (moved to separate file for cleanliness)
web.RegisterRoutes(f)
// alert the user and start the server
log.Println("Server is running...")
log.Println(http.ListenAndServe("0.0.0.0:2830", f))
}