(
params: HashMap<String, String>,
store: Store,
)
| 10 | |
| 11 | #[instrument] |
| 12 | pub 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 | |
| 33 | pub async fn update_question( |
| 34 | id: i32, |
nothing calls this directly
no test coverage detected