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

Function get_questions

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

Source from the content-addressed store, hash-verified

10
11#[instrument]
12pub async fn get_questions(
13 params: HashMap<String, String>,
14 store: Store,
15) -> Result<impl warp::Reply, warp::Rejection> {
16 info!("querying questions");
17 if !params.is_empty() {
18 let pagination = extract_pagination(params)?;
19 info!(pagination = true);
20 let res: Vec<Question> = store.questions.read().await.values().cloned().collect();
21 let res = &res[pagination.start..pagination.end];
22 Ok(warp::reply::json(&res))
23 } else {
24 info!(pagination = false);
25 let res: Vec<Question> = store.questions.read().await.values().cloned().collect();
26 Ok(warp::reply::json(&res))
27 }
28}
29
30pub async fn update_question(
31 id: String,

Callers

nothing calls this directly

Calls 1

extract_paginationFunction · 0.50

Tested by

no test coverage detected