Skip to content

Commit

Permalink
Add echo method for testing / documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Sep 30, 2024
1 parent ac280d2 commit ba8d487
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions deepwell/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ async fn build_module(app_state: ServerState) -> anyhow::Result<RpcModule<Server

// Miscellaneous
register!("ping", ping);
register!("echo", echo);
register!("error", yield_error);
register!("version", version);
register!("version_full", full_version);
Expand Down
11 changes: 11 additions & 0 deletions deepwell/src/endpoints/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use super::prelude::*;
use crate::info;
use sea_orm::{ConnectionTrait, DatabaseBackend, Statement};
use serde_json::Value as JsonValue;
use std::path::PathBuf;
use wikidot_normalize::normalize;

Expand Down Expand Up @@ -57,6 +58,16 @@ pub async fn ping(
Ok("Pong!")
}

pub async fn echo(
_ctx: &ServiceContext<'_>,
params: Params<'static>,
) -> Result<JsonValue> {
// Just write out whatever JSON value they put in
let data: JsonValue = params.parse()?;
info!("Got echo request, sending back to caller");
Ok(data)
}

/// Method which always returns an error.
/// For testing.
pub async fn yield_error(
Expand Down

0 comments on commit ba8d487

Please sign in to comment.