From 0de3e04d680adccd3f455d6a333dee1370a394a4 Mon Sep 17 00:00:00 2001 From: Achim Rohn Date: Sat, 2 Aug 2025 11:35:06 +0200 Subject: [PATCH] Add product editing --- htmx/htmx.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 htmx/htmx.go diff --git a/htmx/htmx.go b/htmx/htmx.go new file mode 100644 index 0000000..d96fb5e --- /dev/null +++ b/htmx/htmx.go @@ -0,0 +1,24 @@ +package htmx + +import ( + "encoding/json" + "ersteller-lib" + "github.com/labstack/echo/v4" +) + +type LocationRedirectParams struct { + Path string `json:"path"` + Target string `json:"target,omitempty"` + Swap string `json:"swap,omitempty"` +} + +func LocationRedirect(c echo.Context, params LocationRedirectParams) error { + jsonData, err := json.Marshal(params) + if err != nil { + ersteller_lib.Error("Failed to marshal LocationRedirectParams ", params, err) + return err + } + ersteller_lib.Debug("LocationRedirectParams", params, "jsonData", string(jsonData)) + c.Response().Header().Set("HX-Location", string(jsonData)) + return nil +}