This commit is contained in:
lbenedar
2026-03-04 15:17:59 +03:00
parent 9085959978
commit 98683f382a
2 changed files with 27 additions and 7 deletions

22
cmd/web/helpers.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import (
"fmt"
"net/http"
"runtime/debug"
)
func (app *application) serverError(w http.ResponseWriter, err error) {
trace := fmt.Sprintf("%s\n%s", err.Error(), debug.Stack())
app.errorLog.Output(2, trace)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
func (app *application) clientError(w http.ResponseWriter, status int) {
http.Error(w, http.StatusText(status), status)
}
func (app *application) notFound(w http.ResponseWriter) {
app.clientError(w, http.StatusNotFound)
}