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",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
|
@ -82,9 +73,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
|||
|
||||
[[package]]
|
||||
name = "axum"
|
||||
version = "0.2.8"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f08f95a202e827209db1491047aa57c18c8adb4c5efcfcfd4a2da4838ee3a72"
|
||||
checksum = "ebef2d70f09908abd9bedd61f62db165e051eb7643c48ab1642b568b685752a0"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bitflags",
|
||||
|
@ -94,8 +85,10 @@ dependencies = [
|
|||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"matchit",
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
|
@ -823,6 +816,12 @@ version = "0.1.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||
|
||||
[[package]]
|
||||
name = "matchit"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58b6f41fdfbec185dd3dff58b51e323f5bc61692c0de38419a957b0dcfccca3c"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
|
@ -1254,8 +1253,6 @@ version = "1.5.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
omegaupload-common = { path = "../common" }
|
||||
anyhow = "1"
|
||||
axum = { version = "0.2", features = ["http2", "headers"] }
|
||||
axum = { version = "0.3", features = ["http2", "headers"] }
|
||||
bincode = "1"
|
||||
# We don't care about which version (We want to match with axum), we just need
|
||||
# to enable the feature
|
||||
|
|
|
@ -22,12 +22,13 @@ use std::time::Duration;
|
|||
|
||||
use anyhow::Result;
|
||||
use axum::body::Bytes;
|
||||
use axum::error_handling::HandleErrorExt;
|
||||
use axum::extract::{Extension, Path, TypedHeader};
|
||||
use axum::handler::{get, post};
|
||||
use axum::http::header::EXPIRES;
|
||||
use axum::http::StatusCode;
|
||||
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 futures::stream::StreamExt;
|
||||
use headers::HeaderMap;
|
||||
|
@ -82,11 +83,12 @@ async fn main() -> Result<()> {
|
|||
let signals_handle = signals.handle();
|
||||
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));
|
||||
|
||||
axum::Server::bind(&"0.0.0.0:8080".parse()?)
|
||||
.serve(
|
||||
.serve({
|
||||
info!("Now serving on 0.0.0.0:8080");
|
||||
Router::new()
|
||||
.route(
|
||||
"/",
|
||||
|
@ -99,8 +101,8 @@ async fn main() -> Result<()> {
|
|||
get(paste::<SHORT_CODE_SIZE>).delete(delete::<SHORT_CODE_SIZE>),
|
||||
)
|
||||
.layer(AddExtensionLayer::new(db))
|
||||
.into_make_service(),
|
||||
)
|
||||
.into_make_service()
|
||||
})
|
||||
.await?;
|
||||
|
||||
// Must be called for correct shutdown
|
||||
|
|
Loading…
Reference in a new issue