diff --git a/Cargo.lock b/Cargo.lock index b0778bc..415bde5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -180,6 +180,17 @@ version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +[[package]] +name = "futures-macro" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.21" @@ -199,9 +210,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-core", + "futures-macro", "futures-task", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -627,9 +640,11 @@ version = "0.0.0" dependencies = [ "async-compression", "axum", + "futures-util", "hyper", "tar", "tokio", + "tokio-util", "tower-http", "tracing", "tracing-subscriber", diff --git a/Cargo.toml b/Cargo.toml index f4e66b4..fc1d055 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,5 @@ tracing-subscriber = {version = "0.3.9", features = ["env-filter"] } tower-http = { version = "0.2.5", features = ["fs", "trace", "auth"] } tar = "0.4.38" async-compression = { version = "0.3.12", features = ["tokio", "gzip"] } +tokio-util = { version = "0.7.1", features = ["io"] } +futures-util = "0.3.21" diff --git a/src/main.rs b/src/main.rs index 60332e4..23f7405 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,9 +5,12 @@ use axum::{ routing::{get_service, post}, Router, }; +use futures_util::TryStreamExt; use hyper::{Body, Request}; +use std::io::ErrorKind; use std::net::SocketAddr; use tar::Archive; +use tokio_util::io::StreamReader; use tower_http::{auth::RequireAuthorizationLayer, services::ServeDir, trace::TraceLayer}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; @@ -54,9 +57,10 @@ async fn main() { .unwrap(); } -async fn post_deploy(body: BodyStream) { - // let tar = GzDecoder::new(body); - let tar = GzipDecoder::new(body); - let mut archive = Archive::new(tar); - archive.unpack("./static").unwrap(); +async fn post_deploy(res: BodyStream) { + let mut read = + StreamReader::new(res.map_err(|axum_err| std::io::Error::new(ErrorKind::Other, axum_err))); + // let tar = GzipDecoder::new(body); + // let mut archive = Archive::new(tar); + // archive.unpack("./static").unwrap(); }