mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-12 09:50:45 +01:00
Simplify todos_index in todos example (#3048)
This commit is contained in:
parent
69a89c00e7
commit
f1c79a459b
1 changed files with 1 additions and 6 deletions
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue