Files
zeekay 795617c313 zip: the module is hanzo.ai/zip
The import path a reader types is the one the org owns, rather than the forge
that happens to host the bytes. hanzo.ai serves the go-import meta and points it
at the same repository, so where the code lives does not change.

The README's `go get` line moves with it — an install instruction naming the old
path is the one leftover a reader would actually follow.
2026-08-23 21:44:55 -07:00

35 lines
675 B
Go

// websocket example — chat-style echo server.
//
// go run ./examples/websocket
// wscat -c ws://localhost:8080/ws
package main
import (
"log"
"hanzo.ai/zip"
"hanzo.ai/zip/middleware"
"hanzo.ai/zip/wsx"
)
func main() {
app := zip.New(zip.Config{AppName: "websocket"})
app.Use(middleware.Recover(), middleware.RequestID())
app.Get("/ws", wsx.Upgrade(func(c *wsx.Conn) error {
log.Printf("ws connection from %s", c.RemoteAddr())
for {
mt, msg, err := c.ReadMessage()
if err != nil {
log.Printf("ws read: %v", err)
return err
}
if err := c.WriteMessage(mt, msg); err != nil {
return err
}
}
}))
log.Fatal(app.Listen(":8080"))
}