~yerinalexey/gtranslate

3f6bdee18d632b76fc3dd50d70023cb26323f3d8 — Alexey Yerin 6 months ago 1526372
web, api: terminate request on parse error

When a parser error occurs, the request is not terminated which causes
the HTML page to be dumped after the error message.
2 files changed, 2 insertions(+), 0 deletions(-)

M api.go
M web.go
M api.go => api.go +1 -0
@@ 25,6 25,7 @@ func CreateApiHandler(settings *TranslateSettings) func(w http.ResponseWriter, r
		translation, err := Translate(settings, from, to, text)
		if err != nil {
			writeError(w, 500, err)
			return
		}

		w.Write([]byte(translation))

M web.go => web.go +1 -0
@@ 27,6 27,7 @@ func CreateWebHandler(tmpl *template.Template, settings *TranslateSettings) func
		translation, err := Translate(settings, from, to, text)
		if err != nil {
			writeError(w, 500, err)
			return
		}

		tmpl.ExecuteTemplate(w, "index", indexPageData{Languages, from, to, text, translation})