From c6e64b816078c0c53a9db27297f2d7af332cce1d Mon Sep 17 00:00:00 2001 From: Drew Bednar Date: Fri, 11 Jul 2025 21:20:19 -0400 Subject: [PATCH] Adding TODO and additional notes in README to correct mdn documentation --- README.md | 2 +- main.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 12d99cd..72b17f0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # learning_sse -Learning Server Side Events. +Learning [Server Side Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events) can be fun. The magic is in setting the `Content Type` header to `text/event-stream`, writing the response in the from of `data: %s \n\n`, and flushing the content of the WriteResponse buffer manually. This is necessary because by default Go will implicitly flush the buffer only once the Handler has returned. diff --git a/main.go b/main.go index ba524a0..51b04e7 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ func SSEHandler(w http.ResponseWriter, r *http.Request) { } func routes() http.Handler { + // TODO add static server and an HTML index with `new EventSource` JS that writes the data message contents into an element on the page mux := http.NewServeMux() mux.HandleFunc("/sse", SSEHandler) return mux