From c790d0ee03e514b2c83a54dfc2894187e155ce83 Mon Sep 17 00:00:00 2001 From: Luiszzzor <130249162+Luiszzzor@users.noreply.github.com> Date: Sat, 30 May 2026 08:59:32 +0200 Subject: [PATCH] fix: update the concurrency middleware to respond with a JSON payload (#798) update the concurrency middleware to respond with a JSON payload instead of plain text when the request limit is reached to be compatible with openai api standard --------- Co-authored-by: Ludwik --- internal/server/concurrency.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/server/concurrency.go b/internal/server/concurrency.go index ea00c3ae..ddb05c13 100644 --- a/internal/server/concurrency.go +++ b/internal/server/concurrency.go @@ -45,7 +45,9 @@ func CreateConcurrencyMiddleware(cfg config.Config) chain.Middleware { return } if !sem.TryAcquire(1) { - http.Error(w, "Too many requests", http.StatusTooManyRequests) + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusTooManyRequests) + w.Write([]byte(`{"error":"Too many requests"}`)) return } defer sem.Release(1)