Adding a CDP method or Web API
Adding a CDP method
1. Add the handler
// crates/obscura-cdp/src/domains/my_domain.rs
use serde_json::{json, Value};
use crate::dispatch::CdpContext;
pub async fn do_thing(
params: &Value,
_ctx: &mut CdpContext,
_session_id: &Option<String>,
) -> Result<Value, String> {
let name = params.get("name")
.and_then(|v| v.as_str())
.ok_or("missing name")?;
// do the work
Ok(json!({ "ok": true, "name": name }))
}2. Register in the dispatcher
3. Test it
Adding a Web API
1. Add the Rust op
2. Register the op
3. Add the JS shim
4. Add a dependency if needed
5. Smoke test
Tips
Worked examples in the tree
Last updated
Was this helpful?

