Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

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

appview/oauth: allow customizing client timeouts in xrpc reqs

Signed-off-by: oppiliappan <me@oppi.li>

authored by

oppiliappan and committed by
Tangled
7725e279 d37f774f

+15 -2
+15 -2
appview/oauth/oauth.go
··· 202 202 exp int64 203 203 lxm string 204 204 dev bool 205 + timeout time.Duration 205 206 } 206 207 207 208 type ServiceClientOpt func(*ServiceClientOpts) 209 + 210 + func DefaultServiceClientOpts() ServiceClientOpts { 211 + return ServiceClientOpts{ 212 + timeout: time.Second * 5, 213 + } 214 + } 208 215 209 216 func WithService(service string) ServiceClientOpt { 210 217 return func(s *ServiceClientOpts) { ··· 240 233 } 241 234 } 242 235 236 + func WithTimeout(timeout time.Duration) ServiceClientOpt { 237 + return func(s *ServiceClientOpts) { 238 + s.timeout = timeout 239 + } 240 + } 241 + 243 242 func (s *ServiceClientOpts) Audience() string { 244 243 return fmt.Sprintf("did:web:%s", s.service) 245 244 } ··· 260 247 } 261 248 262 249 func (o *OAuth) ServiceClient(r *http.Request, os ...ServiceClientOpt) (*xrpc.Client, error) { 263 - opts := ServiceClientOpts{} 250 + opts := DefaultServiceClientOpts() 264 251 for _, o := range os { 265 252 o(&opts) 266 253 } ··· 287 274 }, 288 275 Host: opts.Host(), 289 276 Client: &http.Client{ 290 - Timeout: time.Second * 5, 277 + Timeout: opts.timeout, 291 278 }, 292 279 }, nil 293 280 }