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
|
# Command to run the binary
|
||||||
CMD ["./sse-with-state"]
|
CMD ["./ws-example"]
|
||||||
|
|
@ -5,7 +5,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"sse-with-state/internal/embedded"
|
"ws-example/internal/embedded"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetStaticAssets() fs.FS {
|
func GetStaticAssets() fs.FS {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
module sse-with-state
|
module ws-example
|
||||||
|
|
||||||
go 1.23.0
|
go 1.23.0
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/maddalax/htmgo/framework/service"
|
"github.com/maddalax/htmgo/framework/service"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sse-with-state/__htmgo"
|
"ws-example/__htmgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
||||||
"github.com/maddalax/htmgo/extensions/websocket/ws"
|
"github.com/maddalax/htmgo/extensions/websocket/ws"
|
||||||
"github.com/maddalax/htmgo/framework/h"
|
"github.com/maddalax/htmgo/framework/h"
|
||||||
"github.com/maddalax/htmgo/framework/session"
|
"github.com/maddalax/htmgo/framework/session"
|
||||||
"sse-with-state/partials"
|
"ws-example/partials"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IndexPage(ctx *h.RequestContext) *h.Page {
|
func IndexPage(ctx *h.RequestContext) *h.Page {
|
||||||
|
|
@ -2,13 +2,10 @@ package pages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/maddalax/htmgo/framework/h"
|
"github.com/maddalax/htmgo/framework/h"
|
||||||
"github.com/maddalax/htmgo/framework/session"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func RootPage(ctx *h.RequestContext, children ...h.Ren) h.Ren {
|
func RootPage(ctx *h.RequestContext, children ...h.Ren) h.Ren {
|
||||||
s := session.NewState(ctx)
|
|
||||||
return h.Html(
|
return h.Html(
|
||||||
h.Attribute("data-session-id", string(s.SessionId)),
|
|
||||||
h.HxExtension(h.BaseExtensions()),
|
h.HxExtension(h.BaseExtensions()),
|
||||||
h.Head(
|
h.Head(
|
||||||
h.Link("/public/main.css", "stylesheet"),
|
h.Link("/public/main.css", "stylesheet"),
|
||||||
|
|
@ -12,7 +12,8 @@ type Counter struct {
|
||||||
Decrement func()
|
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)
|
get, set := session.UseState(sessionId, id, 0)
|
||||||
|
|
||||||
var increment = func() {
|
var increment = func() {
|
||||||
|
|
@ -38,7 +39,7 @@ func CounterForm(ctx *h.RequestContext, props CounterProps) *h.Element {
|
||||||
if props.Id == "" {
|
if props.Id == "" {
|
||||||
props.Id = h.GenId(6)
|
props.Id = h.GenId(6)
|
||||||
}
|
}
|
||||||
counter := UseCounter(session.GetSessionId(ctx), props.Id)
|
counter := UseCounter(ctx, props.Id)
|
||||||
|
|
||||||
return h.Div(
|
return h.Div(
|
||||||
h.Attribute("hx-swap", "none"),
|
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