another test Bug Because the responses are to long
This commit is contained in:
parent
ff4aa0f63e
commit
411d44737e
4
main.go
4
main.go
|
@ -43,7 +43,7 @@ func createStreamResponse(fromLanguage, toLanguage, message string) string {
|
||||||
return string(jsonResp)
|
return string(jsonResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func streamResponse(w http.ResponseWriter, fromLanguage, toLanguage string, messages <-chan string) {
|
func streamResponse(w http.ResponseWriter, messages <-chan string) {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
w.Header().Set("Cache-Control", "no-cache")
|
w.Header().Set("Cache-Control", "no-cache")
|
||||||
w.Header().Set("Connection", "keep-alive")
|
w.Header().Set("Connection", "keep-alive")
|
||||||
|
@ -55,7 +55,7 @@ func streamResponse(w http.ResponseWriter, fromLanguage, toLanguage string, mess
|
||||||
}
|
}
|
||||||
|
|
||||||
for msg := range messages {
|
for msg := range messages {
|
||||||
formattedMessage := createStreamResponse(fromLanguage, toLanguage, msg)
|
formattedMessage := createStreamResponse(msg)
|
||||||
fmt.Fprintf(w, " %s\n\n", formattedMessage)
|
fmt.Fprintf(w, " %s\n\n", formattedMessage)
|
||||||
flusher.Flush()
|
flusher.Flush()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue