@@ -0,0 +1,38 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"gardomatic.kleiax.de/lib/client"
|
||||
)
|
||||
|
||||
func (app *application) home(w http.ResponseWriter, r *http.Request) {
|
||||
if app.isAuthenticated(r) {
|
||||
http.Redirect(w, r, webPath("gardens"), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
data := app.newTemplateData(r)
|
||||
app.render(w, http.StatusOK, "home.tmpl", data)
|
||||
}
|
||||
|
||||
func ping(w http.ResponseWriter, _ *http.Request) {
|
||||
_, _ = w.Write([]byte("OK"))
|
||||
}
|
||||
|
||||
func (app *application) healthcheck(w http.ResponseWriter, r *http.Request) {
|
||||
data := app.newTemplateData(r)
|
||||
data.SystemTime = time.Now()
|
||||
data.WebVersion = version
|
||||
health, _, err := client.FromContext(r.Context()).Healthcheck(r.Context())
|
||||
if err != nil {
|
||||
data.HealthError = "Die API ist derzeit nicht erreichbar."
|
||||
} else {
|
||||
data.Health = &health
|
||||
}
|
||||
app.render(w, http.StatusOK, "healthcheck.tmpl", data)
|
||||
}
|
||||
|
||||
func (app *application) privacy(w http.ResponseWriter, r *http.Request) {
|
||||
app.render(w, http.StatusOK, "privacy.tmpl", app.newTemplateData(r))
|
||||
}
|
||||
Reference in New Issue
Block a user