From d07c054f8e30fbddf8f42da573e1fe1ddbb7170b Mon Sep 17 00:00:00 2001 From: nain-F49FF806 <126972030+nain-F49FF806@users.noreply.github.com> Date: Wed, 13 Sep 2023 18:05:21 +0200 Subject: [PATCH] Add readme with instructions Signed-off-by: nain-F49FF806 <126972030+nain-F49FF806@users.noreply.github.com> --- mediator/README.md | 46 ++++++++++++++++++++++++++++++++++++++++++ mediator/src/main.rs | 2 +- mediator/src/routes.rs | 7 ++++++- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 mediator/README.md diff --git a/mediator/README.md b/mediator/README.md new file mode 100644 index 0000000000..a32b656c93 --- /dev/null +++ b/mediator/README.md @@ -0,0 +1,46 @@ +# Aries VCX Mediator + +A mediator service for Aries Agents. + +**Status**: Dev + +## Build + +This project depends on `aries-vcx` and is tightly integrated to work with it. +As such we expect this `mediator` module to be in a subdirectory of aries-vcx repo. +You may transplant it, but expect to change the `Cargo.toml` and adjust the dependencies on aries modules manually. + +When ready it's simple to build. + +```bash +# Dev environment build +cargo build +``` + +## Usage + +You can run and test the produced binary using cargo. + +```bash +cargo run +``` + +### Configurable Options + +Currently the mediator reads the following environment variables. + +```yaml +`ENDPOINT_ROOT`: +- **Description**: This is the address at which the mediator will listen for connections. +- **Default**: "127.0.0.1:8005" +- **Usage**: `ENDPOINT_ROOT=127.0.0.1:3000 cargo run` +``` + +## API + +Currently exposed endpoints. + +```yaml +`/register`: +- **Description** : Shows an Aries Out Of Band (OOB) invitation which can be used to connect to the mediator using a conformant Aries Agent. +``` diff --git a/mediator/src/main.rs b/mediator/src/main.rs index 6bf61bf5f8..5025c7474e 100644 --- a/mediator/src/main.rs +++ b/mediator/src/main.rs @@ -5,7 +5,7 @@ async fn main() { println!("Hello, world!"); load_dot_env(); setup_logging(); - let endpoint_root = std::env::var("ENDPOINT_ROOT").unwrap_or("0.0.0.0:8005".into()); + let endpoint_root = std::env::var("ENDPOINT_ROOT").unwrap_or("127.0.0.1:8005".into()); info!("Endpoint root address {}", endpoint_root); let app_router = mediator::routes::build_router(&endpoint_root).await; axum::Server::bind( diff --git a/mediator/src/routes.rs b/mediator/src/routes.rs index 7b9e539482..5c644b7853 100644 --- a/mediator/src/routes.rs +++ b/mediator/src/routes.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use aries_vcx_core::wallet::indy::IndySdkWallet; use axum::extract::State; use axum::response::Html; -use axum::routing::{get, post}; +use axum::routing::get; use axum::Router; use axum_macros::debug_handler; @@ -27,6 +27,10 @@ pub async fn oob_invite_qr(State(agent): State>>) -> Ht )) } +pub async fn readme() -> Html { + Html("

Please refer to the API section of readme for usage. Thanks.

".into()) +} + pub async fn build_router(endpoint_root: &str) -> Router { let mut agent = Agent::new_demo_agent().await.unwrap(); agent @@ -34,6 +38,7 @@ pub async fn build_router(endpoint_root: &str) -> Router { .await .unwrap(); Router::default() + .route("/", get(readme)) .route("/register", get(oob_invite_qr)) .layer(tower_http::catch_panic::CatchPanicLayer::new()) .with_state(Arc::new(agent))