refactor(http): remove and replace error helpers with standard http.Error

This commit is contained in:
yusing
2025-09-26 23:39:00 +08:00
parent 1409a4e8b9
commit dc1175ad69
2 changed files with 4 additions and 78 deletions

View File

@@ -32,7 +32,7 @@ func PreRequest(p Provider, w http.ResponseWriter, r *http.Request) (proceed boo
}
if !gphttp.GetAccept(r.Header).AcceptHTML() {
gphttp.Forbidden(w, "Captcha is required")
http.Error(w, "Captcha is required", http.StatusForbidden)
return false
}
@@ -45,7 +45,9 @@ func PreRequest(p Provider, w http.ResponseWriter, r *http.Request) (proceed boo
http.Redirect(w, r, r.URL.Path, http.StatusFound)
return false
}
gphttp.Unauthorized(w, err.Error())
log.Warn().Err(err).Str("url", r.URL.String()).Str("remote_addr", r.RemoteAddr).Msg("failed to verify captcha")
http.Error(w, "Failed to verify captcha", http.StatusUnauthorized)
return false
}