From 99662d0ff7e3539809d65203eb3892f15c97ec95 Mon Sep 17 00:00:00 2001 From: Kirill Ivanov Date: Fri, 16 Aug 2024 11:26:39 +0300 Subject: [PATCH] documentation --- libs/blockscout-endpoints/health/src/lib.rs | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/libs/blockscout-endpoints/health/src/lib.rs b/libs/blockscout-endpoints/health/src/lib.rs index 34df37969..33c4b6b6b 100644 --- a/libs/blockscout-endpoints/health/src/lib.rs +++ b/libs/blockscout-endpoints/health/src/lib.rs @@ -1,3 +1,34 @@ +//! Tools for setting up `/health` endpoint. +//! +//! ## Usage +//! (example can be seen in `stats-proto` crate in this repo) +//! +//! 1. In `build.rs` in your crateuse [`add_to_compile_config`], +//! [`proto_files`], and [`includes`] for compiling `health.proto` +//! to rust code using [`prost_build`]. +//! +//! 2. To include the generated code in your project, add the following to `lib.rs` +//! (`/grpc.health.v1.rs` is the file name chosen based on `package` in `.proto` file): +//! ```ignore +//! pub mod grpc { +//! pub mod health { +//! pub mod v1 { +//! include!(concat!(env!("OUT_DIR"), "/grpc.health.v1.rs")); +//! } +//! } +//! } +//! ``` +//! +//! 3. To enable swagger generation, add the following in `api_config_http.yaml`'s +//! http rules: +//! ``` +//! - selector: grpc.health.v1.Health.Check +//! get: /health +//! ``` +//! +//! Now the types should be available in `grpc::health::v1` module, and swagger +//! entry for the endpoint should appear + use std::path::{Path, PathBuf}; use prost_build::Config;