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

Configure Feed

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

test: parse the response

kacaii.dev (Jun 29, 2026, 9:48 PM -0300) e7188f5d b214958d

+16 -31
+1
gleam.toml
··· 13 13 14 14 [dev_dependencies] 15 15 gleeunit = ">= 1.0.0 and < 2.0.0" 16 + gleam_httpc = ">= 5.0.0 and < 6.0.0"
+3
manifest.toml
··· 7 7 # You should check this file into your source control repository. 8 8 9 9 packages = [ 10 + { name = "gleam_erlang", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "1124AD3AA21143E5AF0FC5CF3D9529F6DB8CA03E43A55711B60B6B7B3874375C" }, 10 11 { name = "gleam_http", version = "4.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "82EA6A717C842456188C190AFB372665EA56CE13D8559BF3B1DD9E40F619EE0C" }, 12 + { name = "gleam_httpc", version = "5.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "C545172618D07811494E97AAA4A0FB34DA6F6D0061FDC8041C2F8E3BE2B2E48F" }, 11 13 { name = "gleam_json", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "44FDAA8847BE8FC48CA7A1C089706BD54BADCC4C45B237A992EDDF9F2CDB2836" }, 12 14 { name = "gleam_stdlib", version = "1.0.3", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1F543AFBA5D33DA493E6087F4E4C4F20D899411343512686C98A8ABB2963CF22" }, 13 15 { name = "gleeunit", version = "1.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "EC31ABA74256AEA531EDF8169931D775BBB384FED0A8A1BDC4DD9354E3E21826" }, ··· 15 17 16 18 [requirements] 17 19 gleam_http = { version = ">= 4.3.0 and < 5.0.0" } 20 + gleam_httpc = { version = ">= 5.0.0 and < 6.0.0" } 18 21 gleam_json = { version = ">= 3.1.0 and < 4.0.0" } 19 22 gleam_stdlib = { version = ">= 1.0.0 and < 2.0.0" } 20 23 gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
+12 -31
test/possum_test.gleam
··· 1 - import gleam/http 1 + import gleam/dynamic/decode 2 2 import gleam/http/request 3 - import gleam/option 4 - import gleam/uri 3 + import gleam/httpc 4 + import gleam/json 5 5 import gleeunit 6 6 import possum 7 7 ··· 9 9 gleeunit.main() 10 10 } 11 11 12 - const did = "did:plc:ewvi7nxzyoun6zhxrhs64oiz" 12 + fn did_decoder() -> decode.Decoder(String) { 13 + decode.at(["did"], decode.string) 14 + } 13 15 14 - const pds = "personal.data-server.pds" 16 + const handle = "bsky.app" 15 17 16 - const handle = "gleam.run" 18 + const slingshot = "slingshot.microcosm.blue" 17 19 18 20 pub fn resolve_handle_test() -> Nil { 19 21 let request = 20 22 request.new() 21 - |> request.set_host(pds) 23 + |> request.set_host(slingshot) 22 24 |> possum.resolve_handle(handle) 23 25 24 - assert request.method == http.Get 25 - assert request.query == option.Some("handle=" <> uri.percent_encode(handle)) 26 + let assert Ok(response) = httpc.send(request) 27 + let assert Ok("did:plc:" <> _did) = json.parse(response.body, did_decoder()) 26 28 27 - assert request.host == pds 28 - assert request.path == "xrpc/com.atproto.identity.resolveHandle" 29 - } 30 - 31 - pub fn resolve_did_test() -> Nil { 32 - let request = 33 - request.new() 34 - |> possum.resolve_did_document(did) 35 - 36 - assert request.method == http.Get 37 - assert request.host == "plc.directory" 38 - assert request.path == uri.percent_encode(did) 39 - } 40 - 41 - pub fn resolve_well_known_did_test() -> Nil { 42 - let request = 43 - request.new() 44 - |> possum.resolve_well_known_did(handle) 45 - 46 - assert request.method == http.Get 47 - assert request.host == handle 48 - assert request.path == ".well-known/atproto-did" 29 + Nil 49 30 }