migrate to axum 0.3
This commit is contained in:
parent
a14e3e2afe
commit
8630eaa21e
3 changed files with 20 additions and 21 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
@ -17,15 +17,6 @@ dependencies = [
|
||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aho-corasick"
|
|
||||||
version = "0.7.18"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ansi_term"
|
name = "ansi_term"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
|
@ -82,9 +73,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum"
|
name = "axum"
|
||||||
version = "0.2.8"
|
version = "0.3.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f08f95a202e827209db1491047aa57c18c8adb4c5efcfcfd4a2da4838ee3a72"
|
checksum = "ebef2d70f09908abd9bedd61f62db165e051eb7643c48ab1642b568b685752a0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
@ -94,8 +85,10 @@ dependencies = [
|
||||||
"http",
|
"http",
|
||||||
"http-body",
|
"http-body",
|
||||||
"hyper",
|
"hyper",
|
||||||
|
"matchit",
|
||||||
|
"mime",
|
||||||
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"regex",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
|
@ -823,6 +816,12 @@ version = "0.1.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "matchit"
|
||||||
|
version = "0.4.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "58b6f41fdfbec185dd3dff58b51e323f5bc61692c0de38419a957b0dcfccca3c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.4.1"
|
version = "2.4.1"
|
||||||
|
@ -1254,8 +1253,6 @@ version = "1.5.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
|
||||||
"memchr",
|
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ edition = "2021"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
omegaupload-common = { path = "../common" }
|
omegaupload-common = { path = "../common" }
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
axum = { version = "0.2", features = ["http2", "headers"] }
|
axum = { version = "0.3", features = ["http2", "headers"] }
|
||||||
bincode = "1"
|
bincode = "1"
|
||||||
# We don't care about which version (We want to match with axum), we just need
|
# We don't care about which version (We want to match with axum), we just need
|
||||||
# to enable the feature
|
# to enable the feature
|
||||||
|
|
|
@ -22,12 +22,13 @@ use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use axum::body::Bytes;
|
use axum::body::Bytes;
|
||||||
|
use axum::error_handling::HandleErrorExt;
|
||||||
use axum::extract::{Extension, Path, TypedHeader};
|
use axum::extract::{Extension, Path, TypedHeader};
|
||||||
use axum::handler::{get, post};
|
|
||||||
use axum::http::header::EXPIRES;
|
use axum::http::header::EXPIRES;
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
use axum::response::Html;
|
use axum::response::Html;
|
||||||
use axum::{service, AddExtensionLayer, Router};
|
use axum::routing::{get, post, service_method_routing};
|
||||||
|
use axum::{AddExtensionLayer, Router};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use headers::HeaderMap;
|
use headers::HeaderMap;
|
||||||
|
@ -82,11 +83,12 @@ async fn main() -> Result<()> {
|
||||||
let signals_handle = signals.handle();
|
let signals_handle = signals.handle();
|
||||||
let signals_task = tokio::spawn(handle_signals(signals, Arc::clone(&db)));
|
let signals_task = tokio::spawn(handle_signals(signals, Arc::clone(&db)));
|
||||||
|
|
||||||
let root_service = service::get(ServeDir::new("static"))
|
let root_service = service_method_routing::get(ServeDir::new("static"))
|
||||||
.handle_error(|_| Ok::<_, Infallible>(StatusCode::NOT_FOUND));
|
.handle_error(|_| Ok::<_, Infallible>(StatusCode::NOT_FOUND));
|
||||||
|
|
||||||
axum::Server::bind(&"0.0.0.0:8080".parse()?)
|
axum::Server::bind(&"0.0.0.0:8080".parse()?)
|
||||||
.serve(
|
.serve({
|
||||||
|
info!("Now serving on 0.0.0.0:8080");
|
||||||
Router::new()
|
Router::new()
|
||||||
.route(
|
.route(
|
||||||
"/",
|
"/",
|
||||||
|
@ -99,8 +101,8 @@ async fn main() -> Result<()> {
|
||||||
get(paste::<SHORT_CODE_SIZE>).delete(delete::<SHORT_CODE_SIZE>),
|
get(paste::<SHORT_CODE_SIZE>).delete(delete::<SHORT_CODE_SIZE>),
|
||||||
)
|
)
|
||||||
.layer(AddExtensionLayer::new(db))
|
.layer(AddExtensionLayer::new(db))
|
||||||
.into_make_service(),
|
.into_make_service()
|
||||||
)
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Must be called for correct shutdown
|
// Must be called for correct shutdown
|
||||||
|
|
Loading…
Reference in a new issue