Skip to content

Commit ddde6f1

Browse files
committed
feat: handle streaming for generted clients
1 parent 12f4993 commit ddde6f1

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/codegen/templates/client-with-responses.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ func (c *ClientWithResponses) {{$opid}}{{.Suffix}}WithResponse(ctx context.Conte
119119

120120
// Parse{{genResponseTypeName $opid | ucFirst}} parses an HTTP response from a {{$opid}}WithResponse call
121121
func Parse{{genResponseTypeName $opid | ucFirst}}(rsp *http.Response) (*{{genResponseTypeName $opid}}, error) {
122+
if strings.Contains(rsp.Header.Get("Content-Type"), "text/event-stream") {
123+
return &{{genResponseTypeName $opid}}{
124+
HTTPResponse: rsp,
125+
}, nil
126+
}
127+
122128
bodyBytes, err := io.ReadAll(rsp.Body)
123129
defer func() { _ = rsp.Body.Close() }()
124130
if err != nil {

0 commit comments

Comments
 (0)