fix(api): statusWriter implements http.Flusher for SSE handlers
The logMiddleware wrapper (statusWriter) didn't forward Flush, so
`w.(http.Flusher)` in SSE handlers failed and returned the plain text
"streaming unsupported" with 500. SSE clients (agents_dashboard C++ app)
saw a closed connection with no events.
Add Flush() that delegates to the embedded ResponseWriter when it
implements Flusher. Required for /sse/status and /sse/agents/{id}/logs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -147,6 +147,16 @@ func (sw *statusWriter) WriteHeader(code int) {
|
|||||||
sw.ResponseWriter.WriteHeader(code)
|
sw.ResponseWriter.WriteHeader(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flush forwards to the underlying ResponseWriter when it implements Flusher.
|
||||||
|
// Without this method, the type assertion `w.(http.Flusher)` in the SSE handlers
|
||||||
|
// fails (the wrapper hides the inner Flusher), and the handler aborts with
|
||||||
|
// "streaming unsupported".
|
||||||
|
func (sw *statusWriter) Flush() {
|
||||||
|
if f, ok := sw.ResponseWriter.(http.Flusher); ok {
|
||||||
|
f.Flush()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- Helpers ---
|
// --- Helpers ---
|
||||||
|
|
||||||
func writeJSON(w http.ResponseWriter, status int, v any) {
|
func writeJSON(w http.ResponseWriter, status int, v any) {
|
||||||
|
|||||||
Reference in New Issue
Block a user