@@ -28,6 +28,7 @@ func (m *Monitor) RegisterRoutes(mux *http.ServeMux) {
2828 mux .HandleFunc ("/api/root-topic" , m .handleRootTopic )
2929 mux .HandleFunc ("/api/node-files" , m .handleNodeFiles )
3030 mux .HandleFunc ("/api/unique-cids" , m .handleUniqueCIDs )
31+ mux .HandleFunc ("/api/payload-cids-export" , m .handlePayloadCIDsExport )
3132 mux .HandleFunc ("/api/replication" , m .handleReplication )
3233 mux .HandleFunc ("/api/replication-cids" , m .handleReplicationCIDs )
3334 mux .HandleFunc ("/api/manifest-payload" , m .handleManifestPayload )
@@ -206,6 +207,23 @@ func (m *Monitor) handleUniqueCIDs(w http.ResponseWriter, r *http.Request) {
206207 writeJSON (w , map [string ]interface {}{"cids" : entries , "count" : len (entries )})
207208}
208209
210+ func (m * Monitor ) handlePayloadCIDsExport (w http.ResponseWriter , r * http.Request ) {
211+ m .mu .RLock ()
212+ cids := make ([]string , 0 , len (m .uniqueCIDs ))
213+ for c := range m .uniqueCIDs {
214+ cids = append (cids , c )
215+ }
216+ m .mu .RUnlock ()
217+ sort .Strings (cids )
218+
219+ w .Header ().Set ("Content-Type" , "text/plain; charset=utf-8" )
220+ w .Header ().Set ("Content-Disposition" , `attachment; filename="payload_cids.txt"` )
221+ for _ , c := range cids {
222+ w .Write ([]byte (c ))
223+ w .Write ([]byte ("\n " ))
224+ }
225+ }
226+
209227func (m * Monitor ) handleReplication (w http.ResponseWriter , r * http.Request ) {
210228 if r .Method != http .MethodGet {
211229 writeJSONError (w , "method not allowed" , http .StatusMethodNotAllowed )
0 commit comments