pub mod http_handler;
pub mod method_registry;
pub mod openrpc;
pub mod protocol;
pub mod router;
use serde::{Deserialize, Serialize};
pub use http_handler::{JsonRpcState, handle_jsonrpc};
pub use method_registry::{JsonRpcMethodRegistry, MethodExample, MethodMetadata};
pub use openrpc::generate_openrpc_spec;
pub use protocol::{
JsonRpcErrorResponse, JsonRpcRequest, JsonRpcResponse, JsonRpcResponseType, error_codes, validate_method_name,
};
pub use router::{JsonRpcRequestOrBatch, JsonRpcRouter};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JsonRpcConfig {
#[serde(default)]
pub enabled: bool,
#[serde(default = "default_endpoint_path")]
pub endpoint_path: String,
#[serde(default = "default_true")]
pub enable_batch: bool,
#[serde(default = "default_max_batch_size")]
pub max_batch_size: usize,
}
fn default_endpoint_path() -> String {
"/rpc".to_string()
}
fn default_true() -> bool {
true
}
fn default_max_batch_size() -> usize {
100
}
impl Default for JsonRpcConfig {
fn default() -> Self {
Self {
enabled: true,
endpoint_path: default_endpoint_path(),
enable_batch: default_true(),
max_batch_size: default_max_batch_size(),
}
}
}