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

Function add_question

ch_08/src/routes/question.rs:77–101  ·  view source on GitHub ↗
(
    store: Store,
    new_question: NewQuestion,
)

Source from the content-addressed store, hash-verified

75}
76
77pub async fn add_question(
78 store: Store,
79 new_question: NewQuestion,
80) -> Result<impl warp::Reply, warp::Rejection> {
81 let title = match check_profanity(new_question.title).await {
82 Ok(res) => res,
83 Err(e) => return Err(warp::reject::custom(e)),
84 };
85
86 let content = match check_profanity(new_question.content).await {
87 Ok(res) => res,
88 Err(e) => return Err(warp::reject::custom(e)),
89 };
90
91 let question = NewQuestion {
92 title,
93 content,
94 tags: new_question.tags,
95 };
96
97 match store.add_question(question).await {
98 Ok(question) => Ok(warp::reply::json(&question)),
99 Err(e) => Err(warp::reject::custom(e)),
100 }
101}

Callers

nothing calls this directly

Calls 2

check_profanityFunction · 0.50
add_questionMethod · 0.45

Tested by

no test coverage detected