// Copyright 2022-2023 Debox Network // // Licensed under the Apache License, Version 2.0, or the MIT license , at your option. This file may not be // copied, modified, or distributed except according to those terms. // use std::convert::Infallible; use ipfs_webdav::api::BaseApi; #[tokio::main] async fn main() { env_logger::init(); let api = BaseApi::new(); let dav_server = ipfs_webdav::make_server(api); let make_service = hyper::service::make_service_fn(move |_| { let dav_server = dav_server.clone(); async move { let func = move |req| { let dav_server = dav_server.clone(); async move { Ok::<_, Infallible>(dav_server.handle(req).await) } }; Ok::<_, Infallible>(hyper::service::service_fn(func)) } }); let addr = ([127, 0, 0, 1], 4918).into(); println!("Serving on {}", addr); let _ = hyper::Server::bind(&addr) .serve(make_service) .await .map_err(|e| eprintln!("server error: {}", e)); }