ไลบรารีเซิร์ฟเวอร์
Go แบบเรียลไทม์ด้วย WebSocket เผยแพร่จากบริการ Go ด้วยไลบรารี HTTP อย่างเป็นทางการ
ลงชื่อเข้าใช้เพื่อดูโค้ดตัวอย่างเหล่านี้พร้อมโฮสต์คลัสเตอร์ของคุณเอง ลงชื่อเข้าใช้
ใช้เอเจนต์เขียนโค้ด AI อยู่ใช่ไหม? คัดลอกพรอมต์สำหรับเอเจนต์ ↓
ติดตั้ง go get github.com/pusher/pusher-http-go/v5เผยแพร่อีเวนต์ import pusher "github.com/pusher/pusher-http-go/v5"
client := pusher.Client{
AppID: "YOUR_APP_ID" ,
Key: "YOUR_APP_KEY" ,
Secret: "YOUR_APP_SECRET" ,
Host: "ws.hibira.io" ,
Secure: true ,
}
err := client.Trigger("orders" , "order-shipped" , map [string ]any{"id" : 1024 })พรอมต์สำหรับเอเจนต์ วางข้อความนี้ใน Claude Code, Cursor, GitHub Copilot หรือเอเจนต์เขียนโค้ด AI อื่น แล้วเอเจนต์จะเชื่อม Hibira เข้ากับโปรเจกต์ Go ของคุณด้วยการตั้งค่าด้านบน
Integrate Hibira realtime messaging into this Go project. Hibira is a hosted WebSocket service that speaks the Pusher Channels protocol, so it works with the standard Pusher libraries (here: pusher-http-go, https://github.com/pusher/pusher-http-go) pointed at Hibira instead of pusher.com.
Connection details:
- Host: ws.hibira.io
- Port: 443
- TLS: yes (https)
- App ID: YOUR_APP_ID
- App key: YOUR_APP_KEY
- App secret: YOUR_APP_SECRET (server-side only)
What to do:
1. Look at the project first (framework version, package manager, config and env conventions, where similar integrations live) and follow what it already does.
2. Build one pusher.Client from environment variables at startup and pass it to the handlers or services that publish.
3. If the front end subscribes to private or presence channels, add an HTTP handler that checks the user and responds with client.AuthorizePrivateChannel() or client.AuthorizePresenceChannel().
4. Read the credentials and host from environment variables or the project's config, and add placeholder entries to .env.example (or its equivalent). Never commit real values, and never send the app secret to a browser or mobile app.
5. Always pass the host, port and TLS setting above. The library defaults to pusher.com; where it requires a cluster, use "ap" (the host decides where it connects).
6. If YOUR_APP_KEY or YOUR_APP_SECRET above is still a placeholder, keep it as an env placeholder and tell me where to fill it in rather than inventing a value.
7. When you are done, list the files you changed and tell me how to check it works, for example by publishing a test event and watching it arrive.
Reference setup from the Hibira Go guide (adapt it to the project's structure):
Install:
```shell
go get github.com/pusher/pusher-http-go/v5
```
Publish an event:
```go
import pusher "github.com/pusher/pusher-http-go/v5"
client := pusher.Client{
AppID: "YOUR_APP_ID",
Key: "YOUR_APP_KEY",
Secret: "YOUR_APP_SECRET",
Host: "ws.hibira.io",
Secure: true,
}
err := client.Trigger("orders", "order-shipped", map[string]any{"id": 1024})
```
แทนที่ YOUR_APP_KEY และค่าตัวแทนอื่นด้วยค่าจากแดชบอร์ดของคุณ หรือให้เอเจนต์ปล่อยไว้เป็นตัวแปรสภาพแวดล้อมให้คุณกรอกเอง
หรือเชื่อมต่อเซิร์ฟเวอร์ MCP ของ Hibira แล้วเอเจนต์ของคุณจะสร้างแอปและกรอกข้อมูลรับรองเองได้ เชื่อมต่อเอเจนต์เขียนโค้ด AI ของคุณ →
ใช้ app key และ secret จากแดชบอร์ดของคุณ ช่อง อีเวนต์ และ endpoint การยืนยันสิทธิ์ทำงานเหมือนกับที่ใช้กับ Pusher ทุกประการ ข้อมูลอ้างอิงไลบรารี ↗