Skip to main content

router

Function router 

Source
pub fn router(engine: Arc<MnemoEngine>) -> Router
Expand description

Build a tonic::transport::server::Router serving the Mnemo gRPC API.

The returned router can be composed with other tonic services or served directly via tonic::transport::Server.

§Example

use std::sync::Arc;
use mnemo_grpc::router;

let engine: Arc<mnemo_core::query::MnemoEngine> = /* ... */;
let grpc_router = router(engine);
tonic::transport::Server::builder()
    .add_routes(grpc_router.into_service())
    .serve("[::1]:50051".parse().unwrap())
    .await
    .unwrap();

Reads the bearer secret from MNEMO_AUTH_TOKEN. When set (non-empty), every RPC must carry a matching authorization metadata value or it is rejected with UNAUTHENTICATED. When unset, the server runs open and logs a warning.