api: use fmt.Fprint/Fprintln

Honestly I didn't know it existed at the time of writing gtranslate :)
This commit is contained in:
Alexey Yerin 2021-03-15 19:46:21 +03:00
parent 3f6bdee18d
commit 54be24d1a5
2 changed files with 3 additions and 2 deletions

3
api.go
View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"net/http"
)
@ -28,6 +29,6 @@ func CreateApiHandler(settings *TranslateSettings) func(w http.ResponseWriter, r
return
}
w.Write([]byte(translation))
fmt.Fprint(w, translation)
}
}

View File

@ -7,5 +7,5 @@ import (
func writeError(w http.ResponseWriter, status int, err interface{}) {
w.WriteHeader(status)
w.Write([]byte(fmt.Sprintln(err)))
fmt.Fprintln(w, err)
}