๐Ÿ€ ATproto library for gleam
atproto library gleam
35

Configure Feed

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

possum/did: add decoder

kacaii.dev (Jun 30, 2026, 5:26 PM -0300) 8438e06c ae44f47b

+13 -2
+10
src/possum/did.gleam
··· 9 9 //// including the address of the repo's PDS, the repo's handles, 10 10 //// and the public signing keys. 11 11 12 + import gleam/dynamic/decode 12 13 import gleam/regexp 13 14 import gleam/result 14 15 ··· 76 77 case self.method { 77 78 Plc -> "did:plc:" <> self.identifier 78 79 Web -> "did:web:" <> self.identifier 80 + } 81 + } 82 + 83 + pub fn decoder() -> decode.Decoder(Did) { 84 + use value <- decode.then(decode.string) 85 + 86 + case new(value) { 87 + Ok(did) -> decode.success(did) 88 + Error(_) -> decode.failure(Did(Plc, "wibblewobble"), "DID") 79 89 } 80 90 } 81 91
+3 -2
test/possum_test.gleam
··· 82 82 83 83 let decoder = decode.at(["did"], decode.string) 84 84 85 - let assert Ok("did:plc:" <> _did) = json.parse(response.body, decoder) 85 + let assert Ok(value) = json.parse(response.body, decoder) 86 + let assert Ok(_did) = did.new(value) 86 87 Nil 87 88 } 88 89 ··· 97 98 98 99 let decoder = { 99 100 let empty = decode.dict(decode.dynamic, decode.dynamic) 100 - use _ <- decode.field("did", decode.string) 101 + use _ <- decode.field("did", did.decoder()) 101 102 use _ <- decode.field("didDoc", decode.optional(empty)) 102 103 use _ <- decode.field("handle", decode.string) 103 104 use _ <- decode.field("collections", decode.list(decode.string))