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 <l.czarnota@samsung.com>
This commit is contained in:
Luiszzzor
2026-05-30 08:59:32 +02:00
committed by GitHub
parent 4ca9c478a2
commit c790d0ee03
+3 -1
View File
@@ -45,7 +45,9 @@ func CreateConcurrencyMiddleware(cfg config.Config) chain.Middleware {
return return
} }
if !sem.TryAcquire(1) { 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 return
} }
defer sem.Release(1) defer sem.Release(1)