Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b350fe967 |
10
main.go
10
main.go
@@ -110,8 +110,8 @@ func main() {
|
||||
|
||||
debugLog("Response: %s", string(response))
|
||||
|
||||
// Write response to stdout
|
||||
fmt.Println(string(response))
|
||||
// Write response to stdout with Content-Length framing
|
||||
writeFramed(response)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,11 @@ func readMessage(reader *bufio.Reader) ([]byte, error) {
|
||||
|
||||
func writeResponse(resp interface{}) {
|
||||
data, _ := json.Marshal(resp)
|
||||
fmt.Println(string(data))
|
||||
writeFramed(data)
|
||||
}
|
||||
|
||||
func writeFramed(data []byte) {
|
||||
fmt.Fprintf(os.Stdout, "Content-Length: %d\r\n\r\n%s", len(data), data)
|
||||
}
|
||||
|
||||
func debugLog(format string, args ...interface{}) {
|
||||
|
||||
Reference in New Issue
Block a user