template system
This commit is contained in:
parent
711a68699a
commit
1172e23c16
4 changed files with 89 additions and 3 deletions
15
core.go
15
core.go
|
|
@ -6,6 +6,7 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
|
@ -37,12 +38,15 @@ var mailer *Mailer
|
|||
var basePath string
|
||||
var disableEvents bool = false
|
||||
|
||||
//go:embed all:template
|
||||
var resources embed.FS
|
||||
|
||||
type configContainer struct {
|
||||
Request RequestConfig
|
||||
}
|
||||
|
||||
type App struct {
|
||||
t int // for trancking hooks
|
||||
t int // for tracking hooks
|
||||
chain *chain
|
||||
hooks *Hooks
|
||||
Config *configContainer
|
||||
|
|
@ -88,11 +92,16 @@ func (app *App) Run(router *httprouter.Router) {
|
|||
TemplateEnableStr = "false"
|
||||
}
|
||||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
// if enabled, add public path
|
||||
// if enabled,
|
||||
if TemplateEnable {
|
||||
|
||||
// add public path
|
||||
publicPath := os.Getenv("TEMPLATE_PUBLIC")
|
||||
router.ServeFiles("/public/*filepath", http.Dir(publicPath))
|
||||
|
||||
// templates
|
||||
var template = new(Template)
|
||||
template.NewTemplates(resources)
|
||||
|
||||
}
|
||||
|
||||
useHttpsStr := os.Getenv("App_USE_HTTPS")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue