// Common filters ment to be shared between many endpoints use std::convert::Infallible; use warp::{Filter, Rejection}; use crate::schema::{Block, Db, Transaction}; // Database context for routes pub fn with_db(db: Db) -> impl Filter + Clone { warp::any().map(move || db.clone()) } // Accept only json encoded Transaction body and reject big payloads pub fn transaction_json_body() -> impl Filter + Clone { warp::body::content_length_limit(1024 * 32).and(warp::filters::body::json()) } // Accept only json encoded Transaction body and reject big payloads pub fn block_json_body() -> impl Filter + Clone { warp::body::content_length_limit(1024 * 32).and(warp::body::json()) }