cluade code review changes

This commit is contained in:
2026-02-20 16:38:24 +05:30
parent a048cb0d73
commit f1601020b1
16 changed files with 150 additions and 70 deletions

View File

@@ -59,10 +59,12 @@ func reply(w http.ResponseWriter, data any, p *request.Pager) {
// json data...
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(Detail{
if err := json.NewEncoder(w).Encode(Detail{
Data: data,
Pager: p,
})
}); err != nil {
slog.Error(err.Error())
}
}
func BadRequest(w http.ResponseWriter, err error) {
@@ -92,9 +94,14 @@ func SessionExpired(w http.ResponseWriter) {
}
}
// Deprecated: Use NotAuthorized instead.
func NotAutorized(w http.ResponseWriter) {
NotAuthorized(w)
}
func NotAuthorized(w http.ResponseWriter) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
w.WriteHeader(http.StatusForbidden)
_, writeErr := fmt.Fprint(w, "{\"error\": \"You are not authorized to perform this action\"}")
if writeErr != nil {
slog.Error(writeErr.Error())