this repo has no description
0
fork

Configure Feed

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

apidir example

+41
+41
atproto/identity/apidir/examples_test.go
··· 1 + package apidir 2 + 3 + import ( 4 + "context" 5 + "fmt" 6 + 7 + "github.com/bluesky-social/indigo/atproto/syntax" 8 + ) 9 + 10 + func ExampleAPIDirectory() { 11 + // don't run this as a CI test! 12 + //return 13 + 14 + ctx := context.Background() 15 + 16 + // will connect to the provided identity server (eg, a 'domesday' instance) 17 + dir := NewAPIDirectory("http://localhost:6600") 18 + 19 + handle, _ := syntax.ParseHandle("atproto.com") 20 + did, _ := syntax.ParseDID("did:plc:ewvi7nxzyoun6zhxrhs64oiz") 21 + 22 + // low-level resolution of a handle (`identity.Resolver` interface) 23 + atprotoDID, _ := dir.ResolveHandle(ctx, handle) 24 + fmt.Println(atprotoDID) 25 + 26 + // low-level DID document resolution (`identity.Resolver` interface) 27 + doc, err := dir.ResolveDID(ctx, did) 28 + if err != nil { 29 + panic(err) 30 + } 31 + fmt.Println(doc.Service) 32 + 33 + // higher-level identity resolution with accessors (`identity.Directory` interface) 34 + ident, _ := dir.LookupHandle(ctx, handle) 35 + fmt.Println(ident.PDSEndpoint()) 36 + 37 + /// Output: 38 + // did:plc:ewvi7nxzyoun6zhxrhs64oiz 39 + // [{#atproto_pds AtprotoPersonalDataServer https://enoki.us-east.host.bsky.network}] 40 + // https://enoki.us-east.host.bsky.network 41 + }