MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / handleSubLogs

Method handleSubLogs

internal/serverapi/users.go:896–911  ·  view source on GitHub ↗

handleSubLogs 返回用户的订阅访问日志。

(w http.ResponseWriter, r *http.Request, userID string)

Source from the content-addressed store, hash-verified

894
895// handleSubLogs 返回用户的订阅访问日志。
896func (a *userAPI) handleSubLogs(w http.ResponseWriter, r *http.Request, userID string) {
897 if r.Method != http.MethodGet {
898 writeJSON(w, http.StatusMethodNotAllowed, map[string]any{"error": "method not allowed"})
899 return
900 }
901 limit := 50
902 if v, err := strconv.Atoi(r.URL.Query().Get("limit")); err == nil && v > 0 && v <= 200 {
903 limit = v
904 }
905 logs, err := a.users.ListSubAccessLogs(userID, limit)
906 if err != nil {
907 internalError(w, r, fmt.Errorf("failed to list sub logs: %w", err))
908 return
909 }
910 writeJSON(w, http.StatusOK, map[string]any{"logs": logs})
911}
912
913func (a *userAPI) handleNodeUsage(w http.ResponseWriter, r *http.Request, userID string) {
914 if r.Method != http.MethodGet {

Callers 1

handleUserRoutesMethod · 0.95

Calls 5

internalErrorFunction · 0.85
writeJSONFunction · 0.70
GetMethod · 0.65
QueryMethod · 0.65
ListSubAccessLogsMethod · 0.65

Tested by

no test coverage detected