// Copyright 2023 Harran Ali . All rights reserved. // Copyright (c) 2024 Zeni Kim // Use of this source code is governed by MIT-style // license that can be found in the LICENSE file. 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 { // check if template engine is enable TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE") if TemplateEnableStr == "" { TemplateEnableStr = "false" } TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr) if TemplateEnable { // first, include all compoments type templateData struct { PageCard components.PageCard } // now fill data of the components tmplData := templateData{ PageCard: components.PageCard{ CardTitle: "Golang Framework", CardBody: "Welcome to Goffee", }, } return c.Response.Template("welcome.html", tmplData) } else { message := "{\"message\": \"Welcome to Goffee\"}" return c.Response.Json(message) } } // Show dashboard func WelcomeToDashboard(c *core.Context) *core.Response { message := "{\"message\": \"Welcome to Dashboard\"}" return c.Response.Json(message) }