develop #4
4 changed files with 32 additions and 8 deletions
|
@ -18,8 +18,6 @@ App_KEY_FILE_PATH=tls/server.key
|
|||
###### TEMPLATES ######
|
||||
#######################################
|
||||
TEMPLATE_ENABLE=true
|
||||
TEMPLATE_PUBLIC=storage/public
|
||||
TEMPLATE_COMPONENTS=true
|
||||
|
||||
#######################################
|
||||
###### JWT ######
|
||||
|
@ -46,7 +44,7 @@ POSTGRES_PASSWORD=secret
|
|||
POSTGRES_DB_NAME=db_test
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_SSL_MODE=disable
|
||||
POSTGRES_TIMEZONE=Asia/Dubai
|
||||
POSTGRES_TIMEZONE=America/Argentina/Buenos_Aires
|
||||
|
||||
#_____ SQLITE _____#
|
||||
SQLITE_DB_PATH=storage/sqlite.db
|
||||
|
|
|
@ -6,13 +6,39 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"git.smarteching.com/goffee/core"
|
||||
"git.smarteching.com/goffee/core/template/components"
|
||||
)
|
||||
|
||||
// Show home page
|
||||
func WelcomeHome(c *core.Context) *core.Response {
|
||||
message := "{\"message\": \"Welcome to Goffee\"}"
|
||||
return c.Response.Json(message)
|
||||
|
||||
// check if template engine is enable
|
||||
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
|
||||
if TemplateEnableStr == "" {
|
||||
TemplateEnableStr = "false"
|
||||
}
|
||||
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||
|
||||
if TemplateEnable {
|
||||
type templateData struct {
|
||||
TheTitle components.Title
|
||||
}
|
||||
tmplData := templateData{
|
||||
TheTitle: components.Title{
|
||||
Label: "Welcome to Goffee",
|
||||
},
|
||||
}
|
||||
|
||||
return c.Response.Template("basic.html", tmplData)
|
||||
} else {
|
||||
message := "{\"message\": \"Welcome to Goffee\"}"
|
||||
return c.Response.Json(message)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Show dashboard
|
||||
|
|
2
main.go
2
main.go
|
@ -19,7 +19,7 @@ import (
|
|||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
//go:embed all:templates
|
||||
//go:embed all:storage/templates
|
||||
var resources embed.FS
|
||||
|
||||
// The main function
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
{{template "head" "Sample"}}
|
||||
{{template "head" "Goffee"}}
|
||||
<body>
|
||||
{{template "title" .TheTitle}}
|
||||
<div class="section">
|
||||
Sample page!
|
||||
Welcome to Goffee
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue