From cd180a6d8c0820f7483820bd1e76b404d1633167 Mon Sep 17 00:00:00 2001 From: maddalax Date: Sat, 9 Nov 2024 11:53:33 -0600 Subject: [PATCH] cleanup --- examples/ws-example/main.go | 2 +- examples/ws-example/pages/index.go | 2 +- examples/ws-example/pages/root.go | 7 ++++++- examples/ws-example/pages/ws/metrics.go | 2 +- examples/ws-example/partials/index.go | 2 +- .../state.go => extensions/websocket/session/session.go | 0 extensions/websocket/ws/dispatch.go | 2 +- extensions/websocket/ws/every.go | 2 +- extensions/websocket/ws/handler.go | 2 +- extensions/websocket/ws/listener.go | 2 +- extensions/websocket/ws/register.go | 2 +- framework/h/extensions.go | 2 +- 12 files changed, 16 insertions(+), 11 deletions(-) rename framework/session/state.go => extensions/websocket/session/session.go (100%) diff --git a/examples/ws-example/main.go b/examples/ws-example/main.go index 86c3b0ff..7b880d30 100644 --- a/examples/ws-example/main.go +++ b/examples/ws-example/main.go @@ -3,9 +3,9 @@ package main import ( "github.com/maddalax/htmgo/extensions/websocket" ws2 "github.com/maddalax/htmgo/extensions/websocket/opts" + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/framework/h" "github.com/maddalax/htmgo/framework/service" - "github.com/maddalax/htmgo/framework/session" "io/fs" "net/http" "ws-example/__htmgo" diff --git a/examples/ws-example/pages/index.go b/examples/ws-example/pages/index.go index ad1b6668..2c874616 100644 --- a/examples/ws-example/pages/index.go +++ b/examples/ws-example/pages/index.go @@ -2,9 +2,9 @@ package pages import ( "fmt" + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/extensions/websocket/ws" "github.com/maddalax/htmgo/framework/h" - "github.com/maddalax/htmgo/framework/session" "ws-example/partials" ) diff --git a/examples/ws-example/pages/root.go b/examples/ws-example/pages/root.go index 2f9e5a7a..0e847dd0 100644 --- a/examples/ws-example/pages/root.go +++ b/examples/ws-example/pages/root.go @@ -6,7 +6,12 @@ import ( func RootPage(ctx *h.RequestContext, children ...h.Ren) h.Ren { return h.Html( - h.HxExtension(h.BaseExtensions()), + h.JoinExtensions( + h.HxExtension( + h.BaseExtensions(), + ), + h.HxExtension("ws"), + ), h.Head( h.Link("/public/main.css", "stylesheet"), h.Script("/public/htmgo.js"), diff --git a/examples/ws-example/pages/ws/metrics.go b/examples/ws-example/pages/ws/metrics.go index 529401e9..c13faad5 100644 --- a/examples/ws-example/pages/ws/metrics.go +++ b/examples/ws-example/pages/ws/metrics.go @@ -2,9 +2,9 @@ package ws import ( "fmt" + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/extensions/websocket/ws" "github.com/maddalax/htmgo/framework/h" - "github.com/maddalax/htmgo/framework/session" "runtime" "time" "ws-example/pages" diff --git a/examples/ws-example/partials/index.go b/examples/ws-example/partials/index.go index fae8de9d..50540848 100644 --- a/examples/ws-example/partials/index.go +++ b/examples/ws-example/partials/index.go @@ -1,9 +1,9 @@ package partials import ( + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/extensions/websocket/ws" "github.com/maddalax/htmgo/framework/h" - "github.com/maddalax/htmgo/framework/session" ) type Counter struct { diff --git a/framework/session/state.go b/extensions/websocket/session/session.go similarity index 100% rename from framework/session/state.go rename to extensions/websocket/session/session.go diff --git a/extensions/websocket/ws/dispatch.go b/extensions/websocket/ws/dispatch.go index e76fa396..248b6498 100644 --- a/extensions/websocket/ws/dispatch.go +++ b/extensions/websocket/ws/dispatch.go @@ -2,9 +2,9 @@ package ws import ( "github.com/maddalax/htmgo/extensions/websocket/internal/wsutil" + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/framework/h" "github.com/maddalax/htmgo/framework/service" - "github.com/maddalax/htmgo/framework/session" ) // PushServerSideEvent sends a server side event this specific session diff --git a/extensions/websocket/ws/every.go b/extensions/websocket/ws/every.go index bbe19b79..679d3d54 100644 --- a/extensions/websocket/ws/every.go +++ b/extensions/websocket/ws/every.go @@ -2,9 +2,9 @@ package ws import ( "github.com/maddalax/htmgo/extensions/websocket/internal/wsutil" + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/framework/h" "github.com/maddalax/htmgo/framework/service" - "github.com/maddalax/htmgo/framework/session" "time" ) diff --git a/extensions/websocket/ws/handler.go b/extensions/websocket/ws/handler.go index 72cdff83..2d0bbb7d 100644 --- a/extensions/websocket/ws/handler.go +++ b/extensions/websocket/ws/handler.go @@ -3,7 +3,7 @@ package ws import ( "fmt" "github.com/maddalax/htmgo/extensions/websocket/internal/wsutil" - "github.com/maddalax/htmgo/framework/session" + "github.com/maddalax/htmgo/extensions/websocket/session" "sync" ) diff --git a/extensions/websocket/ws/listener.go b/extensions/websocket/ws/listener.go index 33341ae2..5556331e 100644 --- a/extensions/websocket/ws/listener.go +++ b/extensions/websocket/ws/listener.go @@ -2,8 +2,8 @@ package ws import ( "github.com/maddalax/htmgo/extensions/websocket/internal/wsutil" + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/framework/service" - "github.com/maddalax/htmgo/framework/session" ) func StartListener(locator *service.Locator) { diff --git a/extensions/websocket/ws/register.go b/extensions/websocket/ws/register.go index 76226805..b7350fd0 100644 --- a/extensions/websocket/ws/register.go +++ b/extensions/websocket/ws/register.go @@ -2,8 +2,8 @@ package ws import ( "github.com/maddalax/htmgo/extensions/websocket/internal/wsutil" + "github.com/maddalax/htmgo/extensions/websocket/session" "github.com/maddalax/htmgo/framework/h" - "github.com/maddalax/htmgo/framework/session" "github.com/puzpuzpuz/xsync/v3" "sync" "sync/atomic" diff --git a/framework/h/extensions.go b/framework/h/extensions.go index 52cbe129..8eda90d4 100644 --- a/framework/h/extensions.go +++ b/framework/h/extensions.go @@ -3,7 +3,7 @@ package h import "strings" func BaseExtensions() string { - extensions := []string{"path-deps", "response-targets", "mutation-error", "htmgo", "sse", "ws"} + extensions := []string{"path-deps", "response-targets", "mutation-error", "htmgo", "sse"} if IsDevelopment() { extensions = append(extensions, "livereload") }