···2 alias Atex.IdentityResolver.{Cache, DID, DIDDocument, Handle, Identity}
34 @handle_strategy Application.compile_env(:atex, :handle_resolver_strategy, :dns_first)
056 # TODO: simplify errors
78- def resolve(identifier) do
0000009 # If cache fetch succeeds, then the ok tuple will be retuned by the default `with` behaviour
10- with {:error, :not_found} <- Cache.get(identifier),
11 {:ok, identity} <- do_resolve(identifier),
12 identity <- Cache.insert(identity) do
13 {:ok, identity}
···2 alias Atex.IdentityResolver.{Cache, DID, DIDDocument, Handle, Identity}
34 @handle_strategy Application.compile_env(:atex, :handle_resolver_strategy, :dns_first)
5+ @type options() :: {:skip_cache, boolean()}
67 # TODO: simplify errors
89+ @spec resolve(String.t(), list(options())) :: {:ok, Identity.t()} | {:error, any()}
10+ def resolve(identifier, opts \\ []) do
11+ opts = Keyword.validate!(opts, skip_cache: false)
12+ skip_cache = Keyword.get(opts, :skip_cache)
13+14+ cache_result = if skip_cache, do: {:error, :not_found}, else: Cache.get(identifier)
15+16 # If cache fetch succeeds, then the ok tuple will be retuned by the default `with` behaviour
17+ with {:error, :not_found} <- cache_result,
18 {:ok, identity} <- do_resolve(identifier),
19 identity <- Cache.insert(identity) do
20 {:ok, identity}
-2
lib/atex/identity_resolver/did_document.ex
···68 @spec from_json(map()) :: {:ok, t()} | {:error, Peri.Error.t()}
69 def from_json(%{} = map) do
70 map
71- # TODO: `atomize_keys` instead? Peri doesn't convert nested schemas to atoms but does for the base schema.
72- # Smells like a PR if I've ever smelt one...
73 |> Recase.Enumerable.convert_keys(&Recase.to_snake/1)
74 |> schema()
75 |> case do
···68 @spec from_json(map()) :: {:ok, t()} | {:error, Peri.Error.t()}
69 def from_json(%{} = map) do
70 map
0071 |> Recase.Enumerable.convert_keys(&Recase.to_snake/1)
72 |> schema()
73 |> case do