package main import ( "fmt" "net/http" "path" "runtime/debug" "strings" ) func (app *application) serverError(w http.ResponseWriter, err error) { trace := fmt.Sprintf("%s\n%s", err.Error(), debug.Stack()) app.errorLog.Print(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) } func (app *application) cleanUrl(url string) string { s, _ := strings.CutPrefix(url, "http://") s, _ = strings.CutPrefix(s, "https://") s = path.Base(path.Clean(s)) s = "http://" + s return s }