added Pool to router
This commit is contained in:
parent
1d85839237
commit
876a784e90
1 changed files with 24 additions and 4 deletions
|
|
@ -3,9 +3,12 @@ pub mod structs;
|
||||||
#[cfg(tests)]
|
#[cfg(tests)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
use axum::{routing::*, Router};
|
use crate::engines::kv::logic::body_to_json;
|
||||||
|
use crate::engines::kv::structs::KvSecret;
|
||||||
|
use axum::{routing::*, Router, extract::Path};
|
||||||
|
use sqlx::{Any, Pool};
|
||||||
|
|
||||||
pub fn kv_router() -> Router {
|
pub fn kv_router(pool: Pool<Any>) -> Router<Pool<Any>> {
|
||||||
Router::new()
|
Router::new()
|
||||||
.route("/:mount_path/config", get(get_config))
|
.route("/:mount_path/config", get(get_config))
|
||||||
.route("/:mount_path/config", post(post_config))
|
.route("/:mount_path/config", post(post_config))
|
||||||
|
|
@ -21,6 +24,7 @@ pub fn kv_router() -> Router {
|
||||||
.route("/:mount_path/metadata/*path", delete(delete_meta))
|
.route("/:mount_path/metadata/*path", delete(delete_meta))
|
||||||
.route("/:mount_path/subkeys/*path", get(get_subkeys))
|
.route("/:mount_path/subkeys/*path", get(get_subkeys))
|
||||||
.route("/:mount_path/undelete/*path", post(post_undelete))
|
.route("/:mount_path/undelete/*path", post(post_undelete))
|
||||||
|
.with_state(pool)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_config() -> &'static str {
|
async fn get_config() -> &'static str {
|
||||||
|
|
@ -35,10 +39,26 @@ async fn get_data() -> &'static str {
|
||||||
todo!("not implemented")
|
todo!("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn post_data() -> &'static str {
|
async fn post_data(Path((mount_path, kv_path)): Path<(String, String)>, body: String) -> &'static str {
|
||||||
todo!("not implemented")
|
let mut body_json = body_to_json(body);
|
||||||
|
|
||||||
|
let secret: KvSecret = KvSecret {
|
||||||
|
data: body_json["data"]["password1"].take().to_string(),
|
||||||
|
version: body_json["data"]["version"].take().as_i64(),
|
||||||
|
};
|
||||||
|
log::debug!(
|
||||||
|
"Secret: {}, Content: {}, Version: {}, path: {}",
|
||||||
|
kv_path,
|
||||||
|
secret.data,
|
||||||
|
secret.version.unwrap(),
|
||||||
|
mount_path,
|
||||||
|
);
|
||||||
|
"RoutingTest foo successful"
|
||||||
|
|
||||||
|
// todo!("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// TODO soft delete the secret version at path. can be undone with undelete_secret
|
/// TODO soft delete the secret version at path. can be undone with undelete_secret
|
||||||
// https://developer.hashicorp.com/vault/api-docs/secret/kv/kv-v2#delete-latest-version-of-secret
|
// https://developer.hashicorp.com/vault/api-docs/secret/kv/kv-v2#delete-latest-version-of-secret
|
||||||
// https://developer.hashicorp.com/vault/api-docs/secret/kv/kv-v2#delete-secret-versions
|
// https://developer.hashicorp.com/vault/api-docs/secret/kv/kv-v2#delete-secret-versions
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue