spikard_http/jsonrpc/
mod.rs1pub mod http_handler;
7pub mod method_registry;
8pub mod protocol;
9pub mod router;
10
11use serde::{Deserialize, Serialize};
12
13pub use http_handler::{JsonRpcState, handle_jsonrpc};
14pub use method_registry::{JsonRpcMethodRegistry, MethodExample, MethodMetadata};
15pub use protocol::{
16 JsonRpcErrorResponse, JsonRpcRequest, JsonRpcResponse, JsonRpcResponseType, error_codes, validate_method_name,
17};
18pub use router::{JsonRpcRequestOrBatch, JsonRpcRouter};
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct JsonRpcConfig {
23 #[serde(default)]
25 pub enabled: bool,
26 #[serde(default = "default_endpoint_path")]
28 pub endpoint_path: String,
29 #[serde(default = "default_true")]
31 pub enable_batch: bool,
32 #[serde(default = "default_max_batch_size")]
34 pub max_batch_size: usize,
35}
36
37fn default_endpoint_path() -> String {
38 "/rpc".to_string()
39}
40
41fn default_true() -> bool {
42 true
43}
44
45fn default_max_batch_size() -> usize {
46 100
47}
48
49impl Default for JsonRpcConfig {
50 fn default() -> Self {
51 Self {
52 enabled: true,
53 endpoint_path: default_endpoint_path(),
54 enable_batch: default_true(),
55 max_batch_size: default_max_batch_size(),
56 }
57 }
58}