Move writeError to api.go

Web interface now uses error HTML template instead.
This commit is contained in:
Alexey Yerin 2021-05-10 20:10:51 +03:00
parent b67c4398fc
commit e1c610caf9
2 changed files with 5 additions and 11 deletions

5
api.go
View File

@ -5,6 +5,11 @@ import (
"net/http" "net/http"
) )
func writeError(w http.ResponseWriter, status int, err interface{}) {
w.WriteHeader(status)
fmt.Fprintln(w, err)
}
func CreateApiHandler(settings *TranslateSettings) func(w http.ResponseWriter, req *http.Request) { func CreateApiHandler(settings *TranslateSettings) func(w http.ResponseWriter, req *http.Request) {
return func(w http.ResponseWriter, req *http.Request) { return func(w http.ResponseWriter, req *http.Request) {
from := req.FormValue("from") from := req.FormValue("from")

View File

@ -1,11 +0,0 @@
package main
import (
"fmt"
"net/http"
)
func writeError(w http.ResponseWriter, status int, err interface{}) {
w.WriteHeader(status)
fmt.Fprintln(w, err)
}