diff options
author | 2024-09-28 20:47:27 +0000 | |
---|---|---|
committer | 2024-09-28 22:47:27 +0200 | |
commit | 18b7e00fef97e57374a5207bb284934e3647f64d (patch) | |
tree | 2b737c457db65800b3c3f7ed8f451dc846f5366f /internal/httpclient/request.go | |
parent | [docs] Don't run SQLite on networked storage (#3369) (diff) | |
download | gotosocial-18b7e00fef97e57374a5207bb284934e3647f64d.tar.xz |
[chore] use string formatting package agnostic way of printing request attempts ptr (#3371)
Diffstat (limited to 'internal/httpclient/request.go')
-rw-r--r-- | internal/httpclient/request.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/httpclient/request.go b/internal/httpclient/request.go index dfe51b160..853563945 100644 --- a/internal/httpclient/request.go +++ b/internal/httpclient/request.go @@ -19,6 +19,7 @@ package httpclient import ( "net/http" + "strconv" "time" "github.com/superseriousbusiness/gotosocial/internal/log" @@ -32,6 +33,7 @@ const ( // Request wraps an HTTP request // to add our own retry / backoff. type Request struct { + // Current backoff dur. backoff time.Duration @@ -57,8 +59,7 @@ func WrapRequest(r *http.Request) *Request { // Only add content-type header if a request body exists. entry = entry.WithField("contentType", r.Header.Get("Content-Type")) } - // note our formatting library follows ptr values - entry = entry.WithField("attempt", &rr.attempts) + entry = entry.WithField("attempt", uintPtr{&rr.attempts}) rr.Entry = entry return rr } @@ -73,3 +74,12 @@ func (r *Request) BackOff() time.Duration { } return r.backoff } + +type uintPtr struct{ u *uint } + +func (f uintPtr) String() string { + if f.u == nil { + return "<nil>" + } + return strconv.FormatUint(uint64(*f.u), 10) +} |