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

Function get_questions

ch_04/final/src/main.rs:128–141  ·  view source on GitHub ↗
(
    params: HashMap<String, String>,
    store: Store,
)

Source from the content-addressed store, hash-verified

126}
127
128async fn get_questions(
129 params: HashMap<String, String>,
130 store: Store,
131) -> Result<impl warp::Reply, warp::Rejection> {
132 if !params.is_empty() {
133 let pagination = extract_pagination(params)?;
134 let res: Vec<Question> = store.questions.read().await.values().cloned().collect();
135 let res = &res[pagination.start..pagination.end];
136 Ok(warp::reply::json(&res))
137 } else {
138 let res: Vec<Question> = store.questions.read().await.values().cloned().collect();
139 Ok(warp::reply::json(&res))
140 }
141}
142
143async fn add_question(
144 store: Store,

Callers

nothing calls this directly

Calls 1

extract_paginationFunction · 0.70

Tested by

no test coverage detected