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

Function update_question

ch_08/src/routes/question.rs:33–62  ·  view source on GitHub ↗
(
    id: i32,
    store: Store,
    question: Question,
)

Source from the content-addressed store, hash-verified

31}
32
33pub async fn update_question(
34 id: i32,
35 store: Store,
36 question: Question,
37) -> Result<impl warp::Reply, warp::Rejection> {
38 let title = check_profanity(question.title);
39 let content = check_profanity(question.content);
40
41 let (title, content) = tokio::join!(title, content);
42
43 if title.is_err() {
44 return Err(warp::reject::custom(title.unwrap_err()));
45 }
46
47 if content.is_err() {
48 return Err(warp::reject::custom(content.unwrap_err()));
49 }
50
51 let question = Question {
52 id: question.id,
53 title: title.unwrap(),
54 content: content.unwrap(),
55 tags: question.tags,
56 };
57
58 match store.update_question(question, id).await {
59 Ok(res) => Ok(warp::reply::json(&res)),
60 Err(e) => Err(warp::reject::custom(e)),
61 }
62}
63
64pub async fn delete_question(
65 id: i32,

Callers

nothing calls this directly

Calls 2

check_profanityFunction · 0.50
update_questionMethod · 0.45

Tested by

no test coverage detected