Implement simple health checker

on '/h' endpoint.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This commit is contained in:
Vasyl Gello 2024-07-21 14:22:19 +03:00
parent 9dc84c6abb
commit 1f76d09a04
2 changed files with 10 additions and 0 deletions

View file

@ -53,6 +53,11 @@ func (l *linkWSListener) Close() error {
} }
func (s *wsServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { 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{ c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
Subprotocols: []string{"ygg-ws"}, Subprotocols: []string{"ygg-ws"},
}) })

View file

@ -58,6 +58,11 @@ func (l *linkWSSListener) Close() error {
} }
func (s *wssServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { 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{ c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
Subprotocols: []string{"ygg-ws"}, Subprotocols: []string{"ygg-ws"},
}) })