From 0e8c968aa3cf88315a6365afd2ca7d036bba603b Mon Sep 17 00:00:00 2001 From: patwie Date: Tue, 14 May 2024 15:12:42 +0000 Subject: [PATCH] Add health endpoint Hosting this behind an ALB/ELB requires a health check route. --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b4ea1e6..0008876 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,7 @@ func handleUI() http.Handler { if err != nil { panic(err) } - // Let's hot-patch all calls to firebase DB + // Let's hot-patch all calls to firebase DB return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { originalPath := r.URL.Path originalPath = strings.TrimPrefix(originalPath, "/") @@ -132,7 +132,6 @@ func setupSocketIO() *socketio.Server { Origin: "*", Credentials: true, }) - opts.SetTransports(types.NewSet("polling", "webtransport")) ioo := socketio.NewServer(nil, opts) ioo.On("connection", func(clients ...any) { @@ -243,6 +242,12 @@ func main() { r := setupRouter(documentStore) ioo := setupSocketIO() r.Handle("/socket.io/", ioo.ServeHandler(nil)) + r.Get("/ping", func(w http.ResponseWriter, _ *http.Request) { + _, err := w.Write([]byte("pong")) + if err != nil { + panic(err) + } + }) r.Mount("/", handleUI()) go http.ListenAndServe(":3002", r)