federated-dash/cmd/web/handlers.go

25 lines
545 B
Go
Raw Normal View History

2024-06-25 17:35:30 +00:00
package main
2024-06-25 20:17:08 +00:00
import (
"net/http"
"strings"
)
2024-06-25 17:35:30 +00:00
func (app *application) home(writer http.ResponseWriter, request *http.Request) {
2024-06-25 20:17:08 +00:00
domain := request.Host
domainPieces := strings.Split(domain, ".")
var baseURI string
if len(domainPieces) > 1 {
baseURI = domainPieces[len(domainPieces) - 2] + domainPieces[len(domainPieces) - 1]
} else {
baseURI = domain
}
data := templateData{
AppLinks: getAppLinks(app.tier, baseURI),
Tier: app.tier,
BaseUri: baseURI,
}
app.render(writer, request, http.StatusOK, "home.tmpl.html", data)
2024-06-25 17:35:30 +00:00
}