Update deps

This commit is contained in:
2023-12-10 22:18:23 +01:00
parent 983b63fbed
commit f3cd6db222
3 changed files with 360 additions and 189 deletions

509
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,20 +6,20 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1.33.0", features = ["full"] }
tokio = { version = "1.35.0", features = ["full"] }
tokio-util = { version = "0.7.10", features = ["compat", "io"] }
futures-util = "0.3.29"
axum = { version = "0.6.20", features = ["multipart"] }
axum-prometheus = "0.4.0"
axum = { version = "0.7.2", features = ["multipart"] }
axum-prometheus = "0.5.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"]}
tower-http = { version = "0.4.4", features = ["trace"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"]}
tower-http = { version = "0.5.0", features = ["trace"] }
async-tempfile = "0.4.0"
uuid = "1.5.0"
async-tempfile = "0.5.0"
uuid = "1.6.1"
sentry = { version = "0.31.7", features = ["debug-images"] }
sentry = { version = "0.32.0", features = ["debug-images"] }
tokio-cron-scheduler = "0.9.4"

View File

@@ -1,7 +1,7 @@
use async_tempfile::TempFile;
use axum::{
body::StreamBody,
extract::{BodyStream, Path},
body::Body,
extract::Path,
http::{self, header, Request, StatusCode},
middleware::{self, Next},
response::{AppendHeaders, IntoResponse, Response},
@@ -38,10 +38,7 @@ async fn remove_temp_files() -> Result<(), Box<dyn std::error::Error + Send + Sy
Ok(())
}
async fn convert_file(
Path(file_format): Path<String>,
mut stream: BodyStream,
) -> impl IntoResponse {
async fn convert_file(Path(file_format): Path<String>, body: Body) -> impl IntoResponse {
let prefix = uuid::Uuid::new_v4().to_string();
let tempfile = match TempFile::new_with_name(format!("{prefix}.fb2")).await {
@@ -60,7 +57,9 @@ async fn convert_file(
}
};
while let Some(chunk) = stream.next().await {
let mut data_stream = body.into_data_stream();
while let Some(chunk) = data_stream.next().await {
let data = match chunk {
Ok(v) => v,
Err(err) => {
@@ -118,14 +117,13 @@ async fn convert_file(
let _ = result_file.seek(SeekFrom::Start(0)).await;
let stream = ReaderStream::new(result_file);
let body = StreamBody::new(stream);
let headers = AppendHeaders([(header::CONTENT_LENGTH, content_len)]);
(headers, body).into_response()
(headers, Body::from_stream(stream)).into_response()
}
async fn auth<B>(req: Request<B>, next: Next<B>) -> Result<Response, StatusCode> {
async fn auth(req: Request<axum::body::Body>, next: Next) -> Result<Response, StatusCode> {
let auth_header = req
.headers()
.get(http::header::AUTHORIZATION)
@@ -200,10 +198,8 @@ async fn start_app() {
let app = get_router();
info!("Start webserver...");
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
info!("Webserver shutdown...");
}