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

Function get_questions

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

Source from the content-addressed store, hash-verified

11
12#[instrument]
13pub async fn get_questions(
14 params: HashMap<String, String>,
15 store: Store,
16) -> Result<impl warp::Reply, warp::Rejection> {
17 event!(target: "practical_rust_book", Level::INFO, "querying questions");
18 let mut pagination = Pagination::default();
19
20 if !params.is_empty() {
21 event!(Level::INFO, pagination = true);
22 pagination = extract_pagination(params)?;
23 }
24
25 match store
26 .get_questions(pagination.limit, pagination.offset)
27 .await
28 {
29 Ok(res) => Ok(warp::reply::json(&res)),
30 Err(e) => Err(warp::reject::custom(e)),
31 }
32}
33
34pub async fn update_question(
35 id: i32,

Callers

nothing calls this directly

Calls 2

extract_paginationFunction · 0.50
get_questionsMethod · 0.45

Tested by

no test coverage detected