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

Function add_answer

ch_05/src/routes/answer.rs:10–23  ·  view source on GitHub ↗
(
    store: Store,
    params: HashMap<String, String>,
)

Source from the content-addressed store, hash-verified

8};
9
10pub async fn add_answer(
11 store: Store,
12 params: HashMap<String, String>,
13) -> Result<impl warp::Reply, warp::Rejection> {
14 let answer = Answer {
15 id: AnswerId("1".to_string()),
16 content: params.get("content").unwrap().to_string(),
17 question_id: QuestionId(params.get("questionId").unwrap().to_string()),
18 };
19
20 store.answers.write().await.insert(answer.id.clone(), answer);
21
22 Ok(warp::reply::with_status("Answer added", StatusCode::OK))
23}

Callers

nothing calls this directly

Calls 2

AnswerIdClass · 0.50
QuestionIdClass · 0.50

Tested by

no test coverage detected