Skip to content

Commit

Permalink
fix: header filter on knowledge query (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
sagojez authored Jan 28, 2025
1 parent a01407d commit 47a2a60
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/src/logic/knowledge.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::{read, HookExt, PublicExt, RequestExt};
use super::{read_without_key, HookExt, PublicExt, RequestExt};
use crate::server::{AppState, AppStores};
use axum::{routing::get, Router};
use entities::{Id, MongoStore};
Expand All @@ -8,8 +8,8 @@ use std::sync::Arc;

pub fn get_router() -> Router<Arc<AppState>> {
Router::new()
.route("/", get(read::<ReadRequest, Knowledge>))
.route("/:id", get(read::<ReadRequest, Knowledge>))
.route("/", get(read_without_key::<ReadRequest, Knowledge>))
.route("/:id", get(read_without_key::<ReadRequest, Knowledge>))
}

struct ReadRequest;
Expand Down
12 changes: 12 additions & 0 deletions api/src/logic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,18 @@ where
read_common::<T, U>(headers, access, query, State(state), true).await
}

pub async fn read_without_key<T, U>(
headers: HeaderMap,
query: Option<Query<BTreeMap<String, String>>>,
State(state): State<Arc<AppState>>,
) -> Result<Json<ServerResponse<ReadResponse<Value>>>, PicaError>
where
T: RequestExt<Output = U> + PublicExt<U> + 'static,
U: Serialize + DeserializeOwned + Unpin + Sync + Send + Debug + 'static,
{
read_common::<T, U>(headers, None, query, State(state), true).await
}

pub async fn read_without_count<T, U>(
headers: HeaderMap,
access: Option<Extension<Arc<EventAccess>>>,
Expand Down

0 comments on commit 47a2a60

Please sign in to comment.