2022-03-04 16:01:32 +00:00
|
|
|
// use crate::net::DB;
|
|
|
|
// use hyper::body::Body;
|
2022-02-22 14:16:50 +00:00
|
|
|
// use surrealdb::dbs::export;
|
2022-05-10 07:29:25 +00:00
|
|
|
use crate::net::session;
|
2022-02-22 14:16:50 +00:00
|
|
|
use surrealdb::Session;
|
2020-06-29 15:36:01 +00:00
|
|
|
use warp::Filter;
|
|
|
|
|
|
|
|
pub fn config() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
|
|
|
|
// Set base path
|
|
|
|
let base = warp::path("export").and(warp::path::end());
|
|
|
|
// Set opts method
|
|
|
|
let opts = base.and(warp::options()).map(warp::reply);
|
|
|
|
// Set get method
|
2022-01-13 17:36:41 +00:00
|
|
|
let get = base.and(warp::get()).and(conf::build()).and_then(handler);
|
2020-06-29 15:36:01 +00:00
|
|
|
// Specify route
|
|
|
|
opts.or(get)
|
|
|
|
}
|
|
|
|
|
2022-03-04 16:01:32 +00:00
|
|
|
async fn handler(_session: Session) -> Result<impl warp::Reply, warp::Rejection> {
|
|
|
|
// let db = DB.get().unwrap().clone();
|
|
|
|
// let (chn, body) = Body::channel();
|
2022-02-22 14:16:50 +00:00
|
|
|
// tokio::spawn(export(db, session, chn));
|
2022-03-04 16:01:32 +00:00
|
|
|
// Ok(warp::reply::Response::new(body))
|
|
|
|
Ok(warp::reply::reply())
|
2020-06-29 15:36:01 +00:00
|
|
|
}
|