mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-07 00:00:15 +02:00
Simplify todos_index in todos example (#3048)
This commit is contained in:
@@ -82,14 +82,9 @@ pub struct Pagination {
|
||||
pub limit: Option<usize>,
|
||||
}
|
||||
|
||||
async fn todos_index(
|
||||
pagination: Option<Query<Pagination>>,
|
||||
State(db): State<Db>,
|
||||
) -> impl IntoResponse {
|
||||
async fn todos_index(pagination: Query<Pagination>, State(db): State<Db>) -> impl IntoResponse {
|
||||
let todos = db.read().unwrap();
|
||||
|
||||
let Query(pagination) = pagination.unwrap_or_default();
|
||||
|
||||
let todos = todos
|
||||
.values()
|
||||
.skip(pagination.offset.unwrap_or(0))
|
||||
|
||||
Reference in New Issue
Block a user