don't
5
fork

Configure Feed

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

refactor(knot): delegate resolver initialisation to cli module

Signed-off-by: tjh <x@tjh.dev>

tjh c35ba972 e6152019

+14 -4
+13
crates/knot/src/cli.rs
··· 1 1 use atproto::did::OwnedDid; 2 2 use clap::{ArgAction, Parser, ValueEnum, ValueHint}; 3 3 use gix::bstr::BString; 4 + use identity::HttpClient; 4 5 use knot::model::config::{DEFAULT_READMES, KnotConfiguration, RepoCacheConfig}; 5 6 use std::{env, path::PathBuf, time::Duration}; 7 + use url::Url; 6 8 7 9 pub fn parse() -> Arguments { 8 10 Arguments::parse() ··· 123 121 live: Duration::from_secs(repo_cache_live), 124 122 }, 125 123 }) 124 + } 125 + 126 + pub fn init_resolver(&self, http: HttpClient) -> identity::Resolver { 127 + let plc_url = Url::parse(&self.plc_directory).expect("PLC directory should be a valid URL"); 128 + assert!(["http", "https"].contains(&plc_url.scheme())); 129 + 130 + let resolver = identity::Resolver::builder() 131 + .plc_directory(self.plc_directory.clone()) 132 + .build_with(http); 133 + 134 + resolver 126 135 } 127 136 } 128 137
+1 -4
crates/knot/src/main.rs
··· 4 4 use anyhow::Context as _; 5 5 use axum::http::{Request, Response}; 6 6 use futures_util::FutureExt as _; 7 - use identity::Resolver; 8 7 use knot::{ 9 8 model::{Knot, KnotState, config::KnotConfiguration}, 10 9 services::database::DataStore, ··· 104 105 .build() 105 106 .context("Failed to build public HTTP client")?; 106 107 107 - let resolver = Resolver::builder() 108 - .plc_directory(arguments.plc_directory.clone()) 109 - .build_with(public_http.clone()); 108 + let resolver = arguments.init_resolver(public_http.clone()); 110 109 111 110 // Bind listeners for the public API. 112 111 let mut public_listeners = Vec::with_capacity(arguments.bind.len());