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

Function add_answer

ch_04/final/src/main.rs:183–200  ·  view source on GitHub ↗
(
    store: Store,
    params: HashMap<String, String>,
)

Source from the content-addressed store, hash-verified

181}
182
183async fn add_answer(
184 store: Store,
185 params: HashMap<String, String>,
186) -> Result<impl warp::Reply, warp::Rejection> {
187 let answer = Answer {
188 id: AnswerId("1".to_string()),
189 content: params.get("content").unwrap().to_string(),
190 question_id: QuestionId(params.get("questionId").unwrap().to_string()),
191 };
192
193 store
194 .answers
195 .write()
196 .await
197 .insert(answer.id.clone(), answer);
198
199 Ok(warp::reply::with_status("Answer added", StatusCode::OK))
200}
201
202#[tokio::main]
203async fn main() {

Callers

nothing calls this directly

Calls 2

AnswerIdClass · 0.70
QuestionIdClass · 0.70

Tested by

no test coverage detected