mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-03-30 12:21:58 +00:00
wip: Working on the root handler and have an error
This commit is contained in:
@@ -90,7 +90,7 @@ fn make_api() -> ParentHandler {
|
|||||||
ParentHandler::new()
|
ParentHandler::new()
|
||||||
.subcommand(
|
.subcommand(
|
||||||
"echo",
|
"echo",
|
||||||
ParentHandler::<NoParams, NoParams>::new()
|
ParentHandler::<NoParams>::new()
|
||||||
.subcommand_no_cli(
|
.subcommand_no_cli(
|
||||||
"echo_no_cli",
|
"echo_no_cli",
|
||||||
from_fn(|c: CliContext| {
|
from_fn(|c: CliContext| {
|
||||||
@@ -131,6 +131,34 @@ fn make_api() -> ParentHandler {
|
|||||||
|InheritParams { donde }, _| donde,
|
|InheritParams { donde }, _| donde,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
"fizz",
|
||||||
|
ParentHandler::<InheritParams>::new().root_handler(
|
||||||
|
from_fn(|c: CliContext, _, InheritParams { donde }| {
|
||||||
|
Ok::<_, RpcError>(
|
||||||
|
format!(
|
||||||
|
"Subcommand No Cli: Host {host} Donde = {donde}",
|
||||||
|
host = c.host(),
|
||||||
|
)
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
|id, _| id,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.subcommand(
|
||||||
|
"error",
|
||||||
|
ParentHandler::<InheritParams>::new().root_handler_no_cli(
|
||||||
|
from_fn(|c: CliContext, _, InheritParams { donde }| {
|
||||||
|
Err::<String, _>(RpcError {
|
||||||
|
code: 1,
|
||||||
|
message: "This is an example message".into(),
|
||||||
|
data: None,
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
|id, _| id,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn internal_error(e: impl Display) -> RpcError {
|
pub fn internal_error(e: impl Display) -> RpcError {
|
||||||
|
|||||||
Reference in New Issue
Block a user