gin框架使用sockjs-go原创
# sockjs-go
https://github.com/igm/sockjs-go 官方示例:
import (
"log"
"net/http"
"github.com/igm/sockjs-go/v3/sockjs"
)
func main() {
handler := sockjs.NewHandler("/echo", sockjs.DefaultOptions, echoHandler)
log.Fatal(http.ListenAndServe(":8081", handler))
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
# 在gin框架中使用sockjs-go
https://github.com/igm/sockjs-go/issues/85
# 问题描述
GET http://localhost:8000/echo/info?t=1486141708375 404 (Not Found)
1
# 解决办法
https://github.com/gin-gonic/gin/issues/799
r.Any("/echo/*info", gin.WrapH(k8spod.CreateAttachHandler("/echo")))
注意: 最后的/echo不能增加/结尾
上次更新: 2022/08/24, 18:07:47