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