feat: allow collections without routes

This commit is contained in:
əlemi 2024-10-21 16:11:39 +02:00
parent 37f4d6b607
commit e44a69e93b
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 3 additions and 3 deletions

View file

@ -63,7 +63,7 @@ impl PrintableResult for ListResult {
println!(" + {key}={}", crate::ext::stringify_toml(&value));
}
for (name, endpoint) in collection.route {
for (name, endpoint) in collection.route.unwrap_or_default() {
let url = endpoint.url(collection.client.as_ref().and_then(|x| x.base.as_deref()))
.split('?')
.next()

View file

@ -150,7 +150,7 @@ async fn run_collection_endpoints(
let client = std::sync::Arc::new(collection.client.unwrap_or_default());
let env = std::sync::Arc::new(collection.env.unwrap_or_default());
for (name, mut endpoint) in collection.route {
for (name, mut endpoint) in collection.route.unwrap_or_default() {
if pattern.find(&name).is_none() { continue };
if debug { endpoint.extract = Some(ext::StringOr::T(model::ExtractorConfig::Debug)) };

View file

@ -12,5 +12,5 @@ pub struct PostWomanCollection {
pub env: Option<toml::Table>,
pub include: Option<Vec<String>>,
// it's weird to name it singular but makes more sense in config
pub route: indexmap::IndexMap<String, EndpointConfig>,
pub route: Option<indexmap::IndexMap<String, EndpointConfig>>,
}