rename
This commit is contained in:
parent
dab96a3980
commit
68d84d4e68
17 changed files with 8 additions and 12 deletions
|
|
@ -35,4 +35,4 @@ EXPOSE 3000
|
|||
|
||||
|
||||
# Command to run the binary
|
||||
CMD ["./sse-with-state"]
|
||||
CMD ["./ws-example"]
|
||||
|
|
@ -5,7 +5,7 @@ package main
|
|||
|
||||
import (
|
||||
"io/fs"
|
||||
"sse-with-state/internal/embedded"
|
||||
"ws-example/internal/embedded"
|
||||
)
|
||||
|
||||
func GetStaticAssets() fs.FS {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
module sse-with-state
|
||||
module ws-example
|
||||
|
||||
go 1.23.0
|
||||
|
||||
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/maddalax/htmgo/framework/service"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"sse-with-state/__htmgo"
|
||||
"ws-example/__htmgo"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/maddalax/htmgo/extensions/websocket/ws"
|
||||
"github.com/maddalax/htmgo/framework/h"
|
||||
"github.com/maddalax/htmgo/framework/session"
|
||||
"sse-with-state/partials"
|
||||
"ws-example/partials"
|
||||
)
|
||||
|
||||
func IndexPage(ctx *h.RequestContext) *h.Page {
|
||||
|
|
@ -2,13 +2,10 @@ package pages
|
|||
|
||||
import (
|
||||
"github.com/maddalax/htmgo/framework/h"
|
||||
"github.com/maddalax/htmgo/framework/session"
|
||||
)
|
||||
|
||||
func RootPage(ctx *h.RequestContext, children ...h.Ren) h.Ren {
|
||||
s := session.NewState(ctx)
|
||||
return h.Html(
|
||||
h.Attribute("data-session-id", string(s.SessionId)),
|
||||
h.HxExtension(h.BaseExtensions()),
|
||||
h.Head(
|
||||
h.Link("/public/main.css", "stylesheet"),
|
||||
|
|
@ -12,7 +12,8 @@ type Counter struct {
|
|||
Decrement func()
|
||||
}
|
||||
|
||||
func UseCounter(sessionId session.Id, id string) Counter {
|
||||
func UseCounter(ctx *h.RequestContext, id string) Counter {
|
||||
sessionId := session.GetSessionId(ctx)
|
||||
get, set := session.UseState(sessionId, id, 0)
|
||||
|
||||
var increment = func() {
|
||||
|
|
@ -38,7 +39,7 @@ func CounterForm(ctx *h.RequestContext, props CounterProps) *h.Element {
|
|||
if props.Id == "" {
|
||||
props.Id = h.GenId(6)
|
||||
}
|
||||
counter := UseCounter(session.GetSessionId(ctx), props.Id)
|
||||
counter := UseCounter(ctx, props.Id)
|
||||
|
||||
return h.Div(
|
||||
h.Attribute("hx-swap", "none"),
|
||||
2
framework/assets/dist/htmgo.js
vendored
2
framework/assets/dist/htmgo.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue