From 448ac5f1c2aa667e5822971bd7f661f7a4196ef7 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 6 Feb 2026 02:05:25 -0700 Subject: [PATCH] f: add cmd/ssechat as ServerSentEvents demo --- cmd/ssechat/main.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/ssechat/main.go b/cmd/ssechat/main.go index 962a530..4975f03 100644 --- a/cmd/ssechat/main.go +++ b/cmd/ssechat/main.go @@ -72,7 +72,13 @@ func handleSSE(w http.ResponseWriter, r *http.Request) { return } - // SSE format: one data: line with the full JSON + // SSE format: + // : comment + // event: optional_name + // data: data + // data: more data + // + // : extra newline to end data if msg.Event != "" { fmt.Fprintf(w, "event: %s\n", msg.Event) } @@ -83,11 +89,6 @@ func handleSSE(w http.ResponseWriter, r *http.Request) { } func handleSend(w http.ResponseWriter, r *http.Request) { - if r.Method != http.MethodPost { - http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) - return - } - if err := r.ParseForm(); err != nil { http.Error(w, "Bad form", http.StatusBadRequest) return