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

Function get_questions

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

Source from the content-addressed store, hash-verified

7use handle_errors::Error;
8
9pub async fn get_questions(
10 params: HashMap<String, String>,
11 store: Store,
12) -> Result<impl warp::Reply, warp::Rejection> {
13 if !params.is_empty() {
14 let pagination = extract_pagination(params)?;
15 let res: Vec<Question> = store.questions.read().await.values().cloned().collect();
16 let res = &res[pagination.start..pagination.end];
17 Ok(warp::reply::json(&res))
18 } else {
19 let res: Vec<Question> = store.questions.read().await.values().cloned().collect();
20 Ok(warp::reply::json(&res))
21 }
22}
23
24pub async fn update_question(
25 id: String,

Callers

nothing calls this directly

Calls 1

extract_paginationFunction · 0.50

Tested by

no test coverage detected