Skip to content

Commit

Permalink
resolved linter issue in sse-svelte.
Browse files Browse the repository at this point in the history
Signed-off-by: karthik kalarikal <[email protected]>
  • Loading branch information
karthikkalarikal committed Jan 26, 2025
1 parent cda915a commit 64c4173
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sse-svelte/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// This package implements a simple HTTP server with two main endpoints:
// - `/event`: Provides a Server-Sent Events (SSE) stream to clients.
// - `/time`: Responds with the current time and stores it in a MongoDB collection called "time_collection".
package main

import (
Expand Down Expand Up @@ -60,7 +63,10 @@ func sseHandler(w http.ResponseWriter, r *http.Request) {
case message := <-msgChan:
fmt.Println("case message... sending message")
fmt.Println(message)
fmt.Fprintf(w, "data: %s\n\n", message)
_, err := fmt.Fprintf(w, "data: %s\n\n", message)
if err != nil {
log.Println(err)
}
flusher.Flush()
case <-r.Context().Done():
fmt.Println("Client closed connection")
Expand Down

0 comments on commit 64c4173

Please sign in to comment.