use std::path::PathBuf;
use anyhow::{Context, Result};
pub struct Args {
pub bind: String,
pub root: Option<PathBuf>,
pub allow: Vec<String>,
pub max_age: u32,
pub cache_mb: usize,
pub cache_dir: Option<PathBuf>,
pub timeout_ms: u64,
pub max_inflight: usize,
pub pool_per_url: usize,
pub jobs_dir: Option<PathBuf>,
}
pub fn handle(args: Args) -> Result<()> {
let bind = args
.bind
.parse()
.with_context(|| format!("--bind '{}' is not a socket address (host:port)", args.bind))?;
if args.root.is_none() && args.allow.is_empty() {
eprintln!(
"warning: neither --root nor --allow given: every ?url= will be refused. \
Pass --root <dir> for local GeoTIFFs and/or --allow <url-prefix> for remote COGs."
);
}
surtgis_server::serve_blocking(surtgis_server::ServerConfig {
bind,
allow: args.allow,
root: args.root,
max_age: args.max_age,
cache_mb: args.cache_mb,
cache_dir: args.cache_dir,
timeout_ms: args.timeout_ms,
max_inflight: args.max_inflight,
pool_per_url: args.pool_per_url,
jobs_dir: args.jobs_dir,
})
}