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 }