sse
sse copied to clipboard
add NewClientFromReq method to allow streaming any kind of requests
Allows making sse clients from any kind of requests, not just GET.
I needed that for streaming responses from OpenAI like this:
req, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://api.openai.com/v1/chat/completions", bytes.NewBuffer(body))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+a.authToken)
client := sse.NewClientFromReq(req)
...
Closes https://github.com/r3labs/sse/issues/153