MCPcopy Index your code
hub / github.com/Rust-Web-Development/code / add_question

Function add_question

ch_11/src/routes/question.rs:87–113  ·  view source on GitHub ↗
(
    session: Session,
    store: Store,
    new_question: NewQuestion,
)

Source from the content-addressed store, hash-verified

85}
86
87pub async fn add_question(
88 session: Session,
89 store: Store,
90 new_question: NewQuestion,
91) -> Result<impl warp::Reply, warp::Rejection> {
92 let account_id = session.account_id;
93 let title = match check_profanity(new_question.title).await {
94 Ok(res) => res,
95 Err(e) => return Err(warp::reject::custom(e)),
96 };
97
98 let content = match check_profanity(new_question.content).await {
99 Ok(res) => res,
100 Err(e) => return Err(warp::reject::custom(e)),
101 };
102
103 let question = NewQuestion {
104 title,
105 content,
106 tags: new_question.tags,
107 };
108
109 match store.add_question(question, account_id).await {
110 Ok(question) => Ok(warp::reply::json(&question)),
111 Err(e) => Err(warp::reject::custom(e)),
112 }
113}

Callers

nothing calls this directly

Calls 2

check_profanityFunction · 0.50
add_questionMethod · 0.45

Tested by

no test coverage detected