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

Function get_questions

ch_08/src/routes/question.rs:12–31  ·  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 event!(target: "practical_rust_book", Level::INFO, "querying questions");
17 let mut pagination = Pagination::default();
18
19 if !params.is_empty() {
20 event!(Level::INFO, pagination = true);
21 pagination = extract_pagination(params)?;
22 }
23
24 match store
25 .get_questions(pagination.limit, pagination.offset)
26 .await
27 {
28 Ok(res) => Ok(warp::reply::json(&res)),
29 Err(e) => Err(warp::reject::custom(e)),
30 }
31}
32
33pub async fn update_question(
34 id: i32,

Callers

nothing calls this directly

Calls 2

extract_paginationFunction · 0.50
get_questionsMethod · 0.45

Tested by

no test coverage detected