use std::convert::Infallible; use libpt::log::info; use warp::{Filter, Rejection, Reply}; use crate::{Item, Store}; pub fn with_store(store: Store) -> impl Filter + Clone { warp::any().map(move || store.clone()) } pub fn routes(store: Store) -> impl Filter + Clone { get_store(store.clone()) } // GET /api/v1/store pub fn get_store(store: Store) -> impl Filter + Clone { warp::path!("api" / "v1" / "store") .and(warp::get()) .and(with_store(store)) // .and(warp::body::content_length_limit(2 << 13)) .then(|store: Store| async move { info!("GET /api/v1/store"); warp::reply::json(&store.get().await) }) }