Add ping endpoint
This commit is contained in:
parent
66fbdbf368
commit
a67bac63b6
3 changed files with 18 additions and 0 deletions
|
|
@ -52,6 +52,12 @@ impl From<StoredDocumentVersion> for DocumentVersionWithoutContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct PingResponse {
|
||||||
|
pub server_version: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
#[derive(Debug, Clone, Serialize, JsonSchema)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct DocumentVersion {
|
pub struct DocumentVersion {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ mod create_document;
|
||||||
mod delete_document;
|
mod delete_document;
|
||||||
mod fetch_latest_document_version;
|
mod fetch_latest_document_version;
|
||||||
mod fetch_latest_documents;
|
mod fetch_latest_documents;
|
||||||
|
mod ping;
|
||||||
mod requests;
|
mod requests;
|
||||||
mod update_document;
|
mod update_document;
|
||||||
|
|
||||||
|
|
@ -40,6 +41,7 @@ pub async fn create_server(app_state: AppState) -> Result<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let app = ApiRouter::new()
|
let app = ApiRouter::new()
|
||||||
|
.api_route("/ping", get(ping::ping))
|
||||||
.api_route(
|
.api_route(
|
||||||
"/vaults/:vault_id/documents",
|
"/vaults/:vault_id/documents",
|
||||||
get(fetch_latest_documents::fetch_latest_documents),
|
get(fetch_latest_documents::fetch_latest_documents),
|
||||||
|
|
|
||||||
10
backend/sync_server/src/server/ping.rs
Normal file
10
backend/sync_server/src/server/ping.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
use axum::Json;
|
||||||
|
|
||||||
|
use crate::{database::models::PingResponse, errors::SyncServerError};
|
||||||
|
|
||||||
|
#[axum::debug_handler]
|
||||||
|
pub async fn ping() -> Result<Json<PingResponse>, SyncServerError> {
|
||||||
|
Ok(Json(PingResponse {
|
||||||
|
server_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||||
|
}))
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue