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