diff options
author | Jordan <me@jordan.im> | 2022-11-24 11:15:51 -0700 |
---|---|---|
committer | Jordan <me@jordan.im> | 2022-11-24 11:15:51 -0700 |
commit | 32b68896d5a1fed17bb9bd18b1b36c3ecd352e27 (patch) | |
tree | d509f23434c9b4ea2797ddb45c836b128aba340f | |
parent | ca276b66837ac04bf92de257e5e65d2992f1a547 (diff) | |
download | keep-32b68896d5a1fed17bb9bd18b1b36c3ecd352e27.tar.gz keep-32b68896d5a1fed17bb9bd18b1b36c3ecd352e27.zip |
archive: log /save/ API Message response parameter values; useful info
-rw-r--r-- | archive.go | 13 | ||||
-rw-r--r-- | archive_test.go | 1 | ||||
-rw-r--r-- | keep.go | 4 |
3 files changed, 9 insertions, 9 deletions
@@ -22,8 +22,9 @@ var ( ) type Save struct { - URL string `json:"url"` - Job string `json:"job_id"` + URL string `json:"url"` + Job string `json:"job_id"` + Message string `json:"message"` } type Wayback struct { @@ -68,7 +69,7 @@ func isArchived(url string) (bool, int) { return av.Snapshots.Recent.Available, status } -func archive(accessKey string, secretKey string, URL string) (int, string) { +func archive(accessKey string, secretKey string, URL string) (int, string, string) { params := url.Values{} params.Set("url", URL) @@ -85,14 +86,14 @@ func archive(accessKey string, secretKey string, URL string) (int, string) { if e, _ := err.(net.Error); !e.Timeout() { log.Println("SAVE", err) } - return 0, "" + return 0, "", "" } defer resp.Body.Close() save := &Save{} decoder := json.NewDecoder(resp.Body) if err := decoder.Decode(save); err != nil { log.Println("SAVE", err) - return 0, "" + return 0, "", "" } - return resp.StatusCode, save.Job + return resp.StatusCode, save.Job, save.Message } diff --git a/archive_test.go b/archive_test.go index 842b3b3..d9fc149 100644 --- a/archive_test.go +++ b/archive_test.go @@ -1,7 +1,6 @@ package main import ( - "net/http" "testing" ) @@ -144,9 +144,9 @@ func archiver(accessKey string, secretKey string, db *SqliteDB) { } // Archive, URL is not present in cache or IA - statusCode, jobID := archive(accessKey, secretKey, message.URL) + statusCode, jobID, msg := archive(accessKey, secretKey, message.URL) + log.Println("SAVE", statusCode, message.URL, jobID, msg) db.AddArchived(message, statusCode) - log.Println("SAVE", statusCode, message.URL, jobID) // Limit requests to Wayback API to 15-second intervals time.Sleep(15 * time.Second) |