diff --git a/app/app.go b/app/app.go index 312bce9..81d97b7 100644 --- a/app/app.go +++ b/app/app.go @@ -14,6 +14,7 @@ import ( func Run(configPath *string) { common.Global = common.GetConfig(*configPath) + // setup static resources gin.SetMode(gin.ReleaseMode) router := gin.Default() m := common.InitMinify() @@ -21,6 +22,7 @@ func Run(configPath *string) { html := common.MinifyStatic(m, web.Templates) common.TMPL = common.LoadHTMLToGin(router, html) + // dynamic routes for pages and page fragments router.GET("/", routes.HandleGETIndex) router.GET("/index", routes.HandleGETIndex) router.GET("/index/instances", routes.HandleGETInstancesFragment) @@ -35,9 +37,11 @@ func Run(configPath *string) { router.GET("/login", routes.HandleGETLogin) router.GET("/settings", routes.HandleGETSettings) + // run on all interfaces with port log.Fatal(router.Run(fmt.Sprintf("0.0.0.0:%d", common.Global.Port))) } +// setup static resources under web (css, images, modules, scripts) func ServeStatic(router *gin.Engine, m *minify.M) { css := common.MinifyStatic(m, web.CSS_fs) router.GET("/css/*css", func(c *gin.Context) { diff --git a/app/common/types.go b/app/common/types.go index aeaa9c6..f38ad5c 100644 --- a/app/common/types.go +++ b/app/common/types.go @@ -1,5 +1,9 @@ package common +import "html/template" + +var Global Config + type Config struct { Port int `json:"listenPort"` Organization string `json:"organization"` @@ -8,11 +12,23 @@ type Config struct { API string `json:"apiurl"` } +// variable for html template root +// generated from LoadHTMLToGin +var TMPL *template.Template + +// static served file type containing data and mimetype type StaticFile struct { Data string MimeType MimeType } +// parsed vmpath data (ie node/type/vmid) +type VMPath struct { + Node string + Type string + VMID string +} + // type used for templated