MCPcopy Index your code
hub / github.com/Rust-Web-Development/code / add_answer

Function add_answer

ch_11/src/routes/answer.rs:8–28  ·  view source on GitHub ↗
(
    session: Session,
    store: Store,
    params: HashMap<String, String>,
)

Source from the content-addressed store, hash-verified

6use crate::types::{account::Session, answer::Answer};
7
8pub async fn add_answer(
9 session: Session,
10 store: Store,
11 params: HashMap<String, String>,
12) -> Result<impl warp::Reply, warp::Rejection> {
13 let account_id = session.account_id;
14 let content = match check_profanity(params.get("content").unwrap().to_string()).await {
15 Ok(res) => res,
16 Err(e) => return Err(warp::reject::custom(e)),
17 };
18
19 let answer = Answer {
20 content,
21 question_id: params.get("questionId").unwrap().parse().unwrap(),
22 };
23
24 match store.add_answer(answer, account_id).await {
25 Ok(_) => Ok(warp::reply::with_status("Answer added", StatusCode::OK)),
26 Err(e) => Err(warp::reject::custom(e)),
27 }
28}

Callers

nothing calls this directly

Calls 2

check_profanityFunction · 0.50
add_answerMethod · 0.45

Tested by

no test coverage detected