@@ -125,7 +125,9 @@ func handler(a core.Action, params *handlerParams) func(http.ResponseWriter, *ht
125
125
126
126
var callback streamingCallback [json.RawMessage ]
127
127
if stream {
128
- w .Header ().Set ("Content-Type" , "text/plain" )
128
+ w .Header ().Set ("Content-Type" , "text/event-stream" )
129
+ w .Header ().Set ("Cache-Control" , "no-cache" )
130
+ w .Header ().Set ("Connection" , "keep-alive" )
129
131
w .Header ().Set ("Transfer-Encoding" , "chunked" )
130
132
callback = func (ctx context.Context , msg json.RawMessage ) error {
131
133
_ , err := fmt .Fprintf (w , "data: {\" message\" : %s}\n \n " , msg )
@@ -137,6 +139,8 @@ func handler(a core.Action, params *handlerParams) func(http.ResponseWriter, *ht
137
139
}
138
140
return nil
139
141
}
142
+ } else {
143
+ w .Header ().Set ("Content-Type" , "application/json" )
140
144
}
141
145
142
146
ctx := r .Context ()
@@ -180,7 +184,7 @@ func handler(a core.Action, params *handlerParams) func(http.ResponseWriter, *ht
180
184
return err
181
185
}
182
186
183
- _ , err = fmt .Fprintf (w , `{ "result": %s}\n` , out )
187
+ _ , err = fmt .Fprintf (w , "{ \ " result\ " : %s}\n " , out )
184
188
return err
185
189
}
186
190
}
0 commit comments