Start of streaming shiz

pull/1/head
Jef Roosens 2022-04-01 14:31:09 +02:00
parent 828ee6c533
commit 910711a0f0
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
3 changed files with 26 additions and 5 deletions

15
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -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();
}