MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / add_answer

Function add_answer

ch_08/src/routes/answer.rs:7–28  ·  view source on GitHub ↗
(
    store: Store,
    new_answer: NewAnswer,
)

Source from the content-addressed store, hash-verified

5use crate::types::answer::NewAnswer;
6
7pub async fn add_answer(
8 store: Store,
9 new_answer: NewAnswer,
10) -> Result<impl warp::Reply, warp::Rejection> {
11 let content = match
12 check_profanity(new_answer.content).await {
13 Ok(res) => res,
14 Err(e) => return Err(warp::reject::custom(e)),
15 };
16
17 let answer = NewAnswer {
18 content,
19 question_id: new_answer.question_id,
20 };
21
22 match store.add_answer(answer).await {
23 Ok(_) => {
24 Ok(warp::reply::with_status("Answer added", StatusCode::OK))
25 }
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