From 1f76d09a04f37fbe4aacd46533af4567d4bb74c9 Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Sun, 21 Jul 2024 14:22:19 +0300 Subject: [PATCH] Implement simple health checker on '/h' endpoint. Signed-off-by: Vasyl Gello --- src/core/link_ws.go | 5 +++++ src/core/link_wss.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/core/link_ws.go b/src/core/link_ws.go index 4a65f979..0544614e 100644 --- a/src/core/link_ws.go +++ b/src/core/link_ws.go @@ -53,6 +53,11 @@ func (l *linkWSListener) Close() error { } func (s *wsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/h" { + w.WriteHeader(http.StatusOK) + w.Write([]byte("OK")) + return + } c, err := websocket.Accept(w, r, &websocket.AcceptOptions{ Subprotocols: []string{"ygg-ws"}, }) diff --git a/src/core/link_wss.go b/src/core/link_wss.go index 896c4750..932aa61c 100644 --- a/src/core/link_wss.go +++ b/src/core/link_wss.go @@ -58,6 +58,11 @@ func (l *linkWSSListener) Close() error { } func (s *wssServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == "/h" { + w.WriteHeader(http.StatusOK) + w.Write([]byte("OK")) + return + } c, err := websocket.Accept(w, r, &websocket.AcceptOptions{ Subprotocols: []string{"ygg-ws"}, })