Skip to content

Commit

Permalink
Merge pull request #73 from FTCHD/add-res-data
Browse files Browse the repository at this point in the history
Return Transcription JSON on `handlePostTranscription`
  • Loading branch information
pluja authored Feb 10, 2024
2 parents 41b5dbd + 543ecf5 commit 132a7b3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/api/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 132a7b3

Please sign in to comment.