File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 22package helpers
33
44import (
5+ "encoding/json"
56 "fmt"
67 "os"
78 "path/filepath"
@@ -33,3 +34,25 @@ func SafeOpenFile(filePath string) (*os.File, error) {
3334 // Open the file if the path is deemed safe
3435 return os .Open (absPath )
3536}
37+
38+ // UnmarshalJSON parses the duration from JSON string.
39+ func (d * JSONDuration ) UnmarshalJSON (b []byte ) error {
40+ var s string
41+ if err := json .Unmarshal (b , & s ); err != nil {
42+ return err
43+ }
44+ duration , err := time .ParseDuration (s )
45+ if err != nil {
46+ return err
47+ }
48+ * d = JSONDuration (duration )
49+ return nil
50+ }
51+
52+ // Duration returns the time.Duration value.
53+ func (d JSONDuration ) Duration () time.Duration {
54+ return time .Duration (d )
55+ }
56+
57+ // JSONDuration wraps time.Duration for custom JSON unmarshalling.
58+ type JSONDuration time.Duration
Original file line number Diff line number Diff line change @@ -95,9 +95,9 @@ type ConcurrencyConfig struct {
9595
9696// TimeoutConfig holds custom timeout settings.
9797type TimeoutConfig struct {
98- CustomTimeout time.Duration // Custom timeout for the HTTP client
99- TokenRefreshBufferPeriod time.Duration // Buffer period before token expiry to attempt token refresh
100- TotalRetryDuration time.Duration // Total duration to attempt retries
98+ CustomTimeout time.Duration `json:"CustomTimeout,omitempty"` // Custom timeout for the HTTP client
99+ TokenRefreshBufferPeriod time.Duration `json:"TokenRefreshBufferPeriod,omitempty"` // Buffer period before token expiry to attempt token refresh
100+ TotalRetryDuration time.Duration `json:"TotalRetryDuration,omitempty"` // Total duration to attempt retries
101101}
102102
103103// RedirectConfig holds configuration related to redirect handling.
You can’t perform that action at this time.
0 commit comments