-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implementing knowledge endpoint (#231)
- Loading branch information
Showing
7 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use super::{read, HookExt, PublicExt, RequestExt}; | ||
use crate::server::{AppState, AppStores}; | ||
use axum::{routing::get, Router}; | ||
use entities::{Id, MongoStore}; | ||
use fake::Dummy; | ||
use serde::{Deserialize, Serialize}; | ||
use std::sync::Arc; | ||
|
||
pub fn get_router() -> Router<Arc<AppState>> { | ||
Router::new() | ||
.route("/", get(read::<ReadRequest, Knowledge>)) | ||
.route("/:id", get(read::<ReadRequest, Knowledge>)) | ||
} | ||
|
||
struct ReadRequest; | ||
|
||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, Dummy)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct Knowledge { | ||
#[serde(rename = "_id")] | ||
pub id: Id, | ||
pub connection_platform: String, | ||
pub title: String, | ||
pub knowledge: Option<String>, | ||
} | ||
|
||
impl HookExt<Knowledge> for ReadRequest {} | ||
impl PublicExt<Knowledge> for ReadRequest {} | ||
impl RequestExt for ReadRequest { | ||
type Output = Knowledge; | ||
|
||
fn get_store(stores: AppStores) -> MongoStore<Self::Output> { | ||
stores.knowledge | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters