mrproliu commented on code in PR #188:
URL: https://github.com/apache/skywalking-go/pull/188#discussion_r1676757286
##########
test/plugins/scenarios/mux/main.go:
##########
@@ -54,11 +58,48 @@ func health(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("success"))
}
+var upgrader = websocket.Upgrader{}
+
+func ws(w http.ResponseWriter, r *http.Request) {
+ c, err := upgrader.Upgrade(w, r, nil)
+ if err != nil {
+ log.Print("upgrade:", err)
+ return
+ }
+ defer c.Close()
+ for {
+ mt, message, err := c.ReadMessage()
+ if err != nil {
+ log.Println("read:", err)
+ break
+ }
+ log.Printf("recv: %s", message)
+ err = c.WriteMessage(mt, message)
+ if err != nil {
+ log.Println("write:", err)
+ break
+ }
+ }
+}
+
+func connectWs() {
+ u := url.URL{Scheme: "ws", Host: "localhost:8080", Path: "/ws"}
+ log.Printf("connecting to %s", u.String())
+ c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
+ if err != nil {
+ log.Fatal("dial:", err)
+ }
+ defer c.Close()
+ c.WriteMessage(websocket.TextMessage, []byte("hello from mux test"))
Review Comment:
OK, could you help to create other PR to enhance this framework? I think
this test code should belong to that plugin test is more reasonable, we can put
it in there temporarily.
Also, Could you add a comment to explain why do need to add this framework
in this test case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]