From 543ecf534b7cf928d7af865d3198622c87091789 Mon Sep 17 00:00:00 2001 From: FTCHD <144691102+FTCHD@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:17:07 +0200 Subject: [PATCH] Return Transcription JSON on `handlePostTranscription` --- backend/api/handlers.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/backend/api/handlers.go b/backend/api/handlers.go index ff877f1..586daa2 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -101,9 +101,20 @@ func (s *Server) handlePostTranscription(c *fiber.Ctx) error { return fiber.NewError(fiber.StatusInternalServerError, "Internal server error") } - // Write the JSON to the response body. + // Broadcast transcription to websocket clients s.BroadcastTranscription(res) s.NewTranscriptionCh <- true + + // Convert the transcription to JSON. + json, err := json.Marshal(res) + if err != nil { + // 503 On vacation! + return fiber.NewError(fiber.StatusServiceUnavailable, "On vacation!") + } + + // Write the JSON to the response body. + c.Set("Content-Type", "application/json") + c.Write(json) return nil }