2020-06-29 15:36:01 +00:00
|
|
|
use warp::http;
|
|
|
|
use warp::Filter;
|
|
|
|
|
2022-05-10 00:07:03 +00:00
|
|
|
const MAX: u64 = 1024 * 1024 * 1024 * 4; // 4 GiB
|
|
|
|
|
2020-06-29 15:36:01 +00:00
|
|
|
pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
|
|
|
|
// Set base path
|
|
|
|
let base = warp::path("import").and(warp::path::end());
|
|
|
|
// Set opts method
|
|
|
|
let opts = base.and(warp::options()).map(warp::reply);
|
|
|
|
// Set post method
|
|
|
|
let post = base
|
|
|
|
.and(warp::post())
|
2022-05-10 00:07:03 +00:00
|
|
|
.and(warp::body::content_length_limit(MAX))
|
2020-06-29 15:36:01 +00:00
|
|
|
.and_then(handler);
|
|
|
|
// Specify route
|
|
|
|
opts.or(post)
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn handler() -> Result<impl warp::Reply, warp::Rejection> {
|
|
|
|
Ok(warp::reply::with_status("Ok", http::StatusCode::OK))
|
|
|
|
}
|