aboutsummaryrefslogtreecommitdiffstats
path: root/src/custom_filters.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/custom_filters.rs')
-rw-r--r--src/custom_filters.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/custom_filters.rs b/src/custom_filters.rs
index 86a78d4..7caf71a 100644
--- a/src/custom_filters.rs
+++ b/src/custom_filters.rs
@@ -3,7 +3,7 @@
3use std::convert::Infallible; 3use std::convert::Infallible;
4use warp::{Filter, Rejection}; 4use warp::{Filter, Rejection};
5 5
6use crate::schema::{Db, Transaction}; // `Block` coming later 6use crate::schema::{Block, Db, Transaction};
7 7
8// Database context for routes 8// Database context for routes
9pub fn with_db(db: Db) -> impl Filter<Extract = (Db,), Error = Infallible> + Clone { 9pub fn with_db(db: Db) -> impl Filter<Extract = (Db,), Error = Infallible> + Clone {
@@ -15,7 +15,12 @@ pub fn with_db(db: Db) -> impl Filter<Extract = (Db,), Error = Infallible> + Clo
15// warp::query::<ListOptions>() 15// warp::query::<ListOptions>()
16// } 16// }
17 17
18// Accept only JSON body and reject big payloads 18// Accept only json encoded Transaction body and reject big payloads
19pub fn json_body() -> impl Filter<Extract = (Transaction,), Error = Rejection> + Clone { 19pub fn transaction_json_body() -> impl Filter<Extract = (Transaction,), Error = Rejection> + Clone {
20 warp::body::content_length_limit(1024 * 32).and(warp::body::json())
21}
22
23// Accept only json encoded Transaction body and reject big payloads
24pub fn block_json_body() -> impl Filter<Extract = (Block,), Error = Rejection> + Clone {
20 warp::body::content_length_limit(1024 * 32).and(warp::body::json()) 25 warp::body::content_length_limit(1024 * 32).and(warp::body::json())
21} 26}