Changed HOST env var to DOMAIN

This commit is contained in:
Ross Trottier 2024-07-09 10:11:48 -06:00
parent 40d645859f
commit 54052434b4
2 changed files with 7 additions and 7 deletions

View File

@ -5,12 +5,12 @@ import (
) )
func (app *application) home(writer http.ResponseWriter, request *http.Request) { func (app *application) home(writer http.ResponseWriter, request *http.Request) {
appLinks := getAppLinks(app.tier, app.host) appLinks := getAppLinks(app.tier, app.domain)
data := templateData{ data := templateData{
AppLinks: appLinks, AppLinks: appLinks,
Tier: app.tier, Tier: app.tier,
BaseUri: app.host, BaseUri: app.domain,
} }
app.render(writer, request, http.StatusOK, "home.tmpl.html", data) app.render(writer, request, http.StatusOK, "home.tmpl.html", data)

View File

@ -11,7 +11,7 @@ type application struct {
logger *slog.Logger logger *slog.Logger
templateCache map[string]*template.Template templateCache map[string]*template.Template
tier string tier string
host string domain string
} }
func main() { func main() {
@ -24,9 +24,9 @@ func main() {
if len(tier) == 0 { if len(tier) == 0 {
tier = "starter" tier = "starter"
} }
host := os.Getenv("HOST") domain := os.Getenv("DOMAIN")
if len(host) == 0 { if len(domain) == 0 {
logger.Error("Must specify host name.") logger.Error("Must specify domain name.")
os.Exit(1) os.Exit(1)
} }
//Set up template cache //Set up template cache
@ -40,7 +40,7 @@ func main() {
logger: logger, logger: logger,
templateCache: templateCache, templateCache: templateCache,
tier: tier, tier: tier,
host: host, domain: domain,
} }
err = http.ListenAndServe(":8080", app.routes()) err = http.ListenAndServe(":8080", app.routes())