mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
interface: readme intro
This commit is contained in:
parent
b5b39b63a9
commit
d7379eadf6
4 changed files with 42 additions and 8 deletions
|
@ -46,7 +46,6 @@ opt-level = 1
|
|||
opt-level = 3
|
||||
|
||||
[workspace.dependencies]
|
||||
axum = { version = "0.7.5", default-features = false }
|
||||
async-trait = { version = "0.1.74", default-features = false }
|
||||
bitflags = { version = "2.4.2", default-features = false }
|
||||
borsh = { version = "1.2.1", default-features = false }
|
||||
|
|
|
@ -17,7 +17,7 @@ cuprate-json-rpc = { path = "../json-rpc", default-features = false }
|
|||
cuprate-rpc-types = { path = "../types", features = ["serde", "epee"], default-features = false }
|
||||
cuprate-helper = { path = "../../helper", features = ["asynch"], default-features = false }
|
||||
|
||||
axum = { workspace = true, features = ["json"] }
|
||||
axum = { version = "0.7.5", features = ["json"], default-features = false }
|
||||
serde = { workspace = true }
|
||||
tower = { workspace = true }
|
||||
paste = { workspace = true }
|
||||
|
|
|
@ -1,6 +1,40 @@
|
|||
TODO
|
||||
# `cuprate-rpc-interface`
|
||||
This crate provides Cuprate's RPC _interface_.
|
||||
|
||||
# What
|
||||
```text
|
||||
cuprate-rpc-interface provides these parts
|
||||
│
|
||||
┌────┴────┐
|
||||
┌───────────────────────────┤ ├───────────────────┐
|
||||
▼ ▼ ▼ ▼
|
||||
CLIENT -> ROUTE -> REQUEST -> HANDLER -> RESPONSE -> CLIENT
|
||||
▲ ▲
|
||||
└───┬───┘
|
||||
│
|
||||
You provide this part
|
||||
```
|
||||
|
||||
Everything coming _in_ from a client including:
|
||||
- Any lower-level HTTP stuff
|
||||
- Endpoint routing
|
||||
- Request (de)serialization
|
||||
|
||||
is handled by this crate.
|
||||
|
||||
This is where your [`RpcHandler`] turns this [`Request`] into a [`Response`].
|
||||
|
||||
You hand this `Response` back to `cuprate-rpc-interface` and it will take care of sending it back to the client.
|
||||
|
||||
The main handler used by Cuprate is implemented in the `cuprate-rpc-handler` crate;
|
||||
it implements the regular RPC server modeled after `monerod`.
|
||||
|
||||
# Router
|
||||
|
||||
# Requests, responses, and errors
|
||||
|
||||
# The RPC handler [`Service`](tower::Service)
|
||||
|
||||
# Routes
|
||||
|
||||
# Feature flags
|
||||
List of feature flags for `cuprate-rpc-interface`.
|
||||
|
|
|
@ -9,13 +9,14 @@ use crate::{
|
|||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Router
|
||||
/// Create the RPC router.
|
||||
///
|
||||
/// TODO
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
///
|
||||
/// # Routes
|
||||
/// List of `monerod` routes, [here](https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.h#L97-L189).
|
||||
#[rustfmt::skip]
|
||||
pub fn create_router<H: RpcHandler>() -> Router<H> {
|
||||
// List of `monerod` routes:
|
||||
// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.h#L97-L189>
|
||||
|
||||
Router::new()
|
||||
// JSON-RPC route.
|
||||
.route("/json_rpc", get(json::json_rpc::<H>))
|
||||
|
|
Loading…
Reference in a new issue