+15
-2
appview/oauth/oauth.go
+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) {
···
233
240
}
234
241
}
235
242
243
+
func WithTimeout(timeout time.Duration) ServiceClientOpt {
244
+
return func(s *ServiceClientOpts) {
245
+
s.timeout = timeout
246
+
}
247
+
}
248
+
236
249
func (s *ServiceClientOpts) Audience() string {
237
250
return fmt.Sprintf("did:web:%s", s.service)
238
251
}
···
247
260
}
248
261
249
262
func (o *OAuth) ServiceClient(r *http.Request, os ...ServiceClientOpt) (*xrpc.Client, error) {
250
-
opts := ServiceClientOpts{}
263
+
opts := DefaultServiceClientOpts()
251
264
for _, o := range os {
252
265
o(&opts)
253
266
}
···
274
287
},
275
288
Host: opts.Host(),
276
289
Client: &http.Client{
277
-
Timeout: time.Second * 5,
290
+
Timeout: opts.timeout,
278
291
},
279
292
}, nil
280
293
}