[READ-ONLY] Mirror of https://github.com/andrioid/ublproxy. andrioid.github.io/ublproxy/
adblock adblock-plus-list adblocker privacy-tools proxy-server self-hosted
0

Configure Feed

Select the types of activity you want to include in your feed.

ublproxy / api_activity.go
748 B 37 lines
1package main 2 3import ( 4 "net/http" 5 "strconv" 6) 7 8func (a *apiHandler) handleActivity(w http.ResponseWriter, r *http.Request) { 9 if a.activityLog == nil { 10 writeJSON(w, http.StatusOK, []ActivityEntry{}) 11 return 12 } 13 14 limit := 100 15 if q := r.URL.Query().Get("limit"); q != "" { 16 if n, err := strconv.Atoi(q); err == nil && n > 0 { 17 limit = n 18 } 19 } 20 if limit > 1000 { 21 limit = 1000 22 } 23 24 entries := a.activityLog.Recent(limit) 25 if entries == nil { 26 entries = []ActivityEntry{} 27 } 28 writeJSON(w, http.StatusOK, entries) 29} 30 31func (a *apiHandler) handleActivityStats(w http.ResponseWriter, r *http.Request) { 32 if a.activityLog == nil { 33 writeJSON(w, http.StatusOK, map[string]int{}) 34 return 35 } 36 writeJSON(w, http.StatusOK, a.activityLog.Stats()) 37}