spikard_http/jsonrpc/
mod.rs1pub(crate) mod http_handler;
7pub(crate) mod method_registry;
8pub(crate) mod openrpc;
9pub(crate) mod protocol;
10pub(crate) mod router;
11
12use serde::{Deserialize, Serialize};
13
14#[cfg(not(target_arch = "wasm32"))]
15pub(crate) use http_handler::{JsonRpcState, handle_jsonrpc};
16pub(crate) use method_registry::{JsonRpcMethodRegistry, MethodMetadata};
17#[cfg(not(target_arch = "wasm32"))]
18pub(crate) use openrpc::generate_openrpc_spec;
19#[cfg(not(target_arch = "wasm32"))]
20pub(crate) use router::JsonRpcRouter;
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct JsonRpcConfig {
25 #[serde(default)]
27 pub enabled: bool,
28 #[serde(default = "default_endpoint_path")]
30 pub endpoint_path: String,
31 #[serde(default = "default_true")]
33 pub enable_batch: bool,
34 #[serde(default = "default_max_batch_size")]
36 pub max_batch_size: usize,
37}
38
39fn default_endpoint_path() -> String {
40 "/rpc".to_string()
41}
42
43fn default_true() -> bool {
44 true
45}
46
47fn default_max_batch_size() -> usize {
48 100
49}
50
51impl Default for JsonRpcConfig {
52 fn default() -> Self {
53 Self {
54 enabled: true,
55 endpoint_path: default_endpoint_path(),
56 enable_batch: default_true(),
57 max_batch_size: default_max_batch_size(),
58 }
59 }
60}