package api import ( "net/http" "github.com/owen/vibeproxy/internal/database" ) func (a *API) listRequestLogs(w http.ResponseWriter, r *http.Request) { f := database.LogFilter{ Status: queryInt(r, "status", 0), Search: r.URL.Query().Get("q"), Limit: queryInt(r, "limit", 50), Offset: queryInt(r, "offset", 0), } if id := queryInt(r, "proxy_host_id", 0); id > 0 { id64 := int64(id) f.ProxyHostID = &id64 } logs, total, err := database.QueryRequestLogs(a.db, f) if err != nil { writeError(w, http.StatusInternalServerError, err.Error()) return } writeJSON(w, http.StatusOK, map[string]any{"logs": logs, "total": total}) } func (a *API) listAuditLogs(w http.ResponseWriter, r *http.Request) { limit := queryInt(r, "limit", 50) offset := queryInt(r, "offset", 0) logs, total, err := database.ListAuditLogs(a.db, limit, offset) if err != nil { writeError(w, http.StatusInternalServerError, err.Error()) return } writeJSON(w, http.StatusOK, map[string]any{"logs": logs, "total": total}) }