// ErrorResponse renders an error page for errors given a message and a status code.
ErrorResponse renders an error page for errors given a message and a status code.
// ErrorResponse renders an error page for errors given a message and a status code .
func ErrorResponse(rw http.ResponseWriter, req *http.Request, message string, code int) {
	if req.Header.Get("Accept") == "application/json" {
		var response struct {
			Error string `json:"error"`
		}
		response.Error = message
		writeJSONResponse(rw, code, response)
	} else {
		title := http.StatusText(code)
		rw.WriteHeader(code)
		t := struct {
			Code    int
			Title   string
			Message string
		}{
			Code:    code,
			Title:   title,
			Message: message,
		}
		templates.New().ExecuteTemplate(rw, "error.html", t)
	}
}
func ErrorResponse ( rw http . ResponseWriter , req * http . Request , message string , code int ) { if req . Header . Get ( " " ) == " " { var response struct { Error string `json:"error"` } response . Error = message writeJSONResponse ( rw , code , response ) } else { title := http . StatusText ( code ) rw . WriteHeader ( code ) t := struct { Code int Title string Message string } { Code : code , Title : title , Message : message , } templates . New ( ) . ExecuteTemplate ( rw , " " , t ) } }
ErrorResponse renders an error page for errors given a message and a status code.
ErrorResponse renders an error page for errors given a message and a status code .