Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: server-sent-event example should use c.Writer.CloseNotify() chan #169

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server-sent-event/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ It is Way to send events from server to clients.

Here is Example for SSE with basic authentication using gin.

### How to Run?
## How to Run?

1) Run `` go run main.go ``
1. Run `go run main.go`

2) Open ``http://127.0.0.1:8085`` in browser and authorize with username and password given in main.go and see messages.
2. Open `http://127.0.0.1:8085` in browser and authorize with username and password given in main.go and see messages.
3 changes: 2 additions & 1 deletion server-sent-event/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ func (stream *Event) serveHTTP() gin.HandlerFunc {
// Send new connection to event server
stream.NewClients <- clientChan

defer func() {
go func() {
<-c.Writer.CloseNotify()
// Send closed connection to event server
stream.ClosedClients <- clientChan
}()
Expand Down