企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ package main import ( "fmt" "github.com/gorilla/websocket" "net/http" "time" ) var upgrader = websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, } func home(w http.ResponseWriter, r *http.Request) { //打印客户端头部信息 fmt.Println(r.Header) _, err := upgrader.Upgrade(w, r, nil) if err != nil { fmt.Println(err) } time.Sleep(time.Second * 100) } func main() { http.HandleFunc("/", home) http.ListenAndServe(":20000", nil) } ~~~