From 24b7cf1251696e272ec0b6ce1000a3b8e71d8ff5 Mon Sep 17 00:00:00 2001 From: Ruidy Date: Sat, 25 May 2024 18:21:36 +0200 Subject: [PATCH] redirect with htmx format --- internal/server/auth.go | 2 -- internal/server/handle_auth.go | 3 ++- internal/view/layout/base.templ | 4 ++-- internal/view/layout/base_templ.go | 2 +- internal/view/login.templ | 18 ++++++++---------- internal/view/login_templ.go | 2 +- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/internal/server/auth.go b/internal/server/auth.go index f439adc..6df2515 100644 --- a/internal/server/auth.go +++ b/internal/server/auth.go @@ -6,7 +6,6 @@ import ( "github.com/labstack/echo-contrib/session" "github.com/labstack/echo/v4" - "github.com/labstack/gommon/log" ) const ( @@ -22,7 +21,6 @@ func MakeAuthMiddleware() echo.MiddlewareFunc { } s, err := readSession(c) - log.Warnf("%=v", s) if s != "bar" || err != nil { return c.Redirect(http.StatusSeeOther, routeLogin) } diff --git a/internal/server/handle_auth.go b/internal/server/handle_auth.go index 8a9e8c1..5b81e7e 100644 --- a/internal/server/handle_auth.go +++ b/internal/server/handle_auth.go @@ -41,6 +41,7 @@ func handleLogin(as *auth.Service) echo.HandlerFunc { if err := sess.Save(c.Request(), c.Response()); err != nil { return err } - return c.Redirect(http.StatusSeeOther, "/bookings") + c.Response().Header().Add("HX-Redirect", "/bookings") + return c.NoContent(200) } } diff --git a/internal/view/layout/base.templ b/internal/view/layout/base.templ index abdf492..c21abd3 100644 --- a/internal/view/layout/base.templ +++ b/internal/view/layout/base.templ @@ -12,7 +12,7 @@ templ BaseLayout() { - + -
+
{ children... }
🏨 RentEase © 2024
diff --git a/internal/view/layout/base_templ.go b/internal/view/layout/base_templ.go index 4bb584d..10e723a 100644 --- a/internal/view/layout/base_templ.go +++ b/internal/view/layout/base_templ.go @@ -23,7 +23,7 @@ func BaseLayout() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("RentEase | Your Property Management System
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("RentEase | Your Property Management System
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/view/login.templ b/internal/view/login.templ index f9d3346..34683d8 100644 --- a/internal/view/login.templ +++ b/internal/view/login.templ @@ -6,15 +6,13 @@ import ( templ Login() { @layout.BaseLayout() { -
-
-

Welcome

-
- - - -
-
-
+
+

Welcome

+
+ + + +
+
} } diff --git a/internal/view/login_templ.go b/internal/view/login_templ.go index 9bb217a..b4c086b 100644 --- a/internal/view/login_templ.go +++ b/internal/view/login_templ.go @@ -33,7 +33,7 @@ func Login() templ.Component { templ_7745c5c3_Buffer = templ.GetBuffer() defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Welcome

") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Welcome

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }