this repo has no description
0
fork

Configure Feed

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

simple http client for web did

authored by

Brian Olson and committed by
Brian Olson
1f22a51a 6e3c2e3e

+9 -1
+9 -1
did/web.go
··· 6 6 "fmt" 7 7 "net/http" 8 8 "strings" 9 + "time" 9 10 "unicode" 10 11 11 12 "github.com/whyrusleeping/go-did" 12 13 "go.opentelemetry.io/otel" 13 14 ) 15 + 16 + var webDidDefaultTimeout = 5 * time.Second 14 17 15 18 type WebResolver struct { 16 19 Insecure bool 17 20 // TODO: cache? maybe at a different layer 21 + 22 + client http.Client 18 23 } 19 24 20 25 func (wr *WebResolver) GetDocument(ctx context.Context, didstr string) (*Document, error) { 26 + if wr.client.Timeout == 0 { 27 + wr.client.Timeout = webDidDefaultTimeout 28 + } 21 29 ctx, span := otel.Tracer("did").Start(ctx, "didWebGetDocument") 22 30 defer span.End() 23 31 ··· 36 44 proto = "http" 37 45 } 38 46 39 - resp, err := http.Get(proto + "://" + val + "/.well-known/did.json") 47 + resp, err := wr.client.Get(proto + "://" + val + "/.well-known/did.json") 40 48 if err != nil { 41 49 return nil, err 42 50 }