Skip to content

Commit 110e771

Browse files
committed
Document NewClient() changes
Signed-off-by: Tim Ekl <[email protected]>
1 parent 06583f8 commit 110e771

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ Fine! The `Stream` object is entirely convenience. It runs no background routine
8383
You betcha.
8484

8585
## Create my own clients
86-
Clients have to be created off an `http.ResponseWriter` that supports the `http.Flusher` and `http.CloseNotifier` interfaces.
86+
Clients have to be created off an `http.ResponseWriter` that supports the `http.Flusher` and `http.CloseNotifier` interfaces. When creating a client, callers can optionally also pass the original `http.Request` being served, which helps determine which headers are appropriate to send in response.
8787

8888
`NewClient` _does_ kick off a background routine to handle sending events, so constructing an object literal will not work. This is done because it's assumed you will likely be calling `NewClient` on an http handler routine, and will likely not be doing any interesting work on that routine.
8989

9090
```go
9191
func ServeHTTP(w http.ResponseWriter, r *http.Request) {
92-
client := eventsource.NewClient(w)
92+
client := eventsource.NewClient(w, r)
9393
if client == nil {
9494
http.Error(...)
9595
return

0 commit comments

Comments
 (0)