Fix deploy: force Docker rebuild, add version check and redeploy script
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
@@ -9,6 +10,7 @@ import (
|
||||
"shop/internal/auth"
|
||||
"shop/internal/models"
|
||||
"shop/internal/repository"
|
||||
"shop/internal/version"
|
||||
)
|
||||
|
||||
type CustomerHandler struct {
|
||||
@@ -26,6 +28,7 @@ type shopPage struct {
|
||||
Title string
|
||||
User *models.User
|
||||
CartCount int
|
||||
Version string
|
||||
Products interface{}
|
||||
Categories interface{}
|
||||
Error string
|
||||
@@ -73,13 +76,14 @@ func NewCustomerHandler(
|
||||
|
||||
func (h *CustomerHandler) render(w http.ResponseWriter, name string, data any) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||
if err := h.templates.ExecuteTemplate(w, name, data); err != nil {
|
||||
log.Printf("render %s: %v", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *CustomerHandler) basePage(r *http.Request, w http.ResponseWriter, title string) shopPage {
|
||||
p := shopPage{Title: title}
|
||||
p := shopPage{Title: title, Version: version.Version}
|
||||
if uid, ok := auth.UserIDFromSession(h.userSession, r); ok {
|
||||
if u, err := h.users.GetByID(r.Context(), uid); err == nil {
|
||||
p.User = &u
|
||||
@@ -373,5 +377,6 @@ func (h *CustomerHandler) Account(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func (h *CustomerHandler) Health(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Write([]byte(`{"status":"ok"}`))
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
fmt.Fprintf(w, `{"status":"ok","version":%q}`, version.Version)
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
<div class="footer__brand">
|
||||
<span class="logo__icon">◆</span>
|
||||
<span class="logo__text">Shop</span>
|
||||
<p class="footer__copy">© 2026 Shop. Все права защищены.</p>
|
||||
<p class="footer__copy">© 2026 Shop · v{{.Version}}</p>
|
||||
</div>
|
||||
<div class="footer__links">
|
||||
<a href="/account">Личный кабинет</a>
|
||||
|
||||
Reference in New Issue
Block a user