use crate::agentic::http::path::parse_path;
use crate::golem_agentic::golem::agent::common::{AuthDetails, CorsOptions, HttpMountDetails};
use crate::agentic::http::validations::reject_query_param_in_string;
pub fn get_http_mount_details(
path: &str,
auth: bool,
phantom_agent: bool,
cors_options: CorsOptions,
web_suffix: Option<String>,
) -> Result<HttpMountDetails, String> {
reject_query_param_in_string(path, "HTTP mount path")?;
let segments = parse_path(path).map_err(|e| e.to_string())?;
let web_suffix = match web_suffix {
Some(suffix) => {
reject_query_param_in_string(&suffix, "webhook_suffix")?;
let parsed_suffix = parse_path(&suffix).map_err(|e| e.to_string())?;
if parsed_suffix.is_empty() {
return Err("webhook_suffix cannot be empty if provided".to_string());
}
parsed_suffix
}
None => vec![],
};
Ok(HttpMountDetails {
path_prefix: segments,
auth_details: Some(AuthDetails { required: auth }),
phantom_agent,
cors_options: cors_options.clone(),
webhook_suffix: web_suffix,
})
}