Upgrade axum to 0.3
Diff
Cargo.lock | 94 +++++++++++++++++++++++++++++++++++++++++---------------------------------------
chartered-git/Cargo.toml | 2 +-
chartered-web/Cargo.toml | 4 ++--
chartered-web/src/main.rs | 25 +------------------------
chartered-web/src/endpoints/cargo_api/mod.rs | 20 ++++----------------
chartered-web/src/endpoints/web_api/mod.rs | 38 +++++++++++---------------------------
chartered-web/src/endpoints/web_api/auth/mod.rs | 33 +++++++--------------------------
chartered-web/src/endpoints/web_api/crates/mod.rs | 34 ++++++++++++----------------------
chartered-web/src/endpoints/web_api/organisations/mod.rs | 30 ++++++++++--------------------
chartered-web/src/endpoints/web_api/users/mod.rs | 23 ++++-------------------
10 files changed, 83 insertions(+), 220 deletions(-)
@@ -51,15 +51,15 @@
[[package]]
name = "anyhow"
version = "1.0.44"
version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"
checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7"
[[package]]
name = "arrayvec"
version = "0.7.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be4dc07131ffa69b8072d35f5007352af944213cde02545e2103680baed38fcd"
checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
[[package]]
name = "async-trait"
@@ -260,9 +260,9 @@
[[package]]
name = "axum"
version = "0.2.8"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f08f95a202e827209db1491047aa57c18c8adb4c5efcfcfd4a2da4838ee3a72"
checksum = "49c3f630b925c7a85089ff794fdce495c88c80d38710f31eb9817c8399fd77ce"
dependencies = [
"async-trait",
"bitflags",
@@ -272,8 +272,10 @@
"http",
"http-body",
"hyper",
"matchit",
"mime",
"percent-encoding",
"pin-project-lite",
"regex",
"serde",
"serde_json",
"serde_urlencoded",
@@ -664,9 +666,9 @@
[[package]]
name = "crc"
version = "2.0.0"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10c2722795460108a7872e1cd933a85d6ec38abc4baecad51028f702da28889f"
checksum = "49fc9a695bca7f35f5f4c15cddc84415f66a74ea78eef08e90c5024f2b540e23"
dependencies = [
"crc-catalog",
]
@@ -1293,9 +1295,9 @@
[[package]]
name = "libc"
version = "0.2.105"
version = "0.2.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "869d572136620d55835903746bcb5cdc54cb2851fd0aeec53220b4bb65ef3013"
checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673"
[[package]]
name = "libsodium-sys"
@@ -1336,15 +1338,6 @@
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
[[package]]
name = "matchers"
version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1"
dependencies = [
"regex-automata",
]
[[package]]
@@ -1352,6 +1345,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 = "md5"
@@ -1606,9 +1605,9 @@
[[package]]
name = "openssl"
version = "0.10.36"
version = "0.10.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a"
checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"
dependencies = [
"bitflags",
"cfg-if",
@@ -1626,9 +1625,9 @@
[[package]]
name = "openssl-sys"
version = "0.9.67"
version = "0.9.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058"
checksum = "c6517987b3f8226b5da3661dad65ff7f300cc59fb5ea8333ca191fc65fde3edf"
dependencies = [
"autocfg",
"cc",
@@ -1907,15 +1906,6 @@
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
@@ -2518,9 +2508,9 @@
[[package]]
name = "tokio"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2c2416fdedca8443ae44b4527de1ea633af61d8f7169ffa6e72c5b53d24efcc"
checksum = "588b2d10a336da58d877567cd8fb8a14b463e2104910f8132cd054b4b96e29ee"
dependencies = [
"autocfg",
"bytes",
@@ -2538,9 +2528,9 @@
[[package]]
name = "tokio-macros"
version = "1.5.0"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2dd85aeaba7b68df939bd357c6afb36c87951be9e80bf9c859f2fc3e9fca0fd"
checksum = "114383b041aa6212c579467afa0075fbbdd0718de036100bc0ba7961d8cb9095"
dependencies = [
"proc-macro2",
"quote",
@@ -2570,9 +2560,9 @@
[[package]]
name = "tokio-stream"
version = "0.1.7"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f"
checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3"
dependencies = [
"futures-core",
"pin-project-lite",
@@ -2581,9 +2571,9 @@
[[package]]
name = "tokio-util"
version = "0.6.8"
version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d3725d3efa29485e87311c5b699de63cde14b00ed4d256b8318aa30ca452cd"
checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0"
dependencies = [
"bytes",
"futures-core",
@@ -2704,39 +2694,21 @@
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-serde"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb65ea441fbb84f9f6748fd496cf7f63ec9af5bca94dd86456978d055e8eb28b"
dependencies = [
"serde",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.2.25"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71"
checksum = "80a4ddde70311d8da398062ecf6fc2c309337de6b0f77d6c27aff8d53f6fca52"
dependencies = [
"ansi_term",
"chrono",
"lazy_static",
"matchers",
"regex",
"serde",
"serde_json",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
"tracing-serde",
]
[[package]]
@@ -34,5 +34,5 @@
tokio-util = { version = "0.6", features = ["codec"] }
toml = "0.5"
tracing = "0.1"
tracing-subscriber = "0.2"
tracing-subscriber = "0.3"
url = "2"
@@ -11,7 +11,7 @@
chartered-fs = { path = "../chartered-fs" }
chartered-types = { path = "../chartered-types" }
axum = { version = "0.2", features = ["headers"] }
axum = { version = "0.3", features = ["headers"] }
base64 = "0.13"
bcrypt = "0.10"
bytes = "1"
@@ -38,5 +38,5 @@
tower-http = { git = "https://github.com/tower-rs/tower-http", branch = "cors", features = ["trace", "set-header", "cors"] }
toml = "0.5"
tracing = "0.1"
tracing-subscriber = "0.2"
tracing-subscriber = "0.3"
url = { version = "2.2", features = ["serde"] }
@@ -7,8 +7,8 @@
mod middleware;
use axum::{
handler::get,
http::{header, Method},
routing::get,
AddExtensionLayer, Router,
};
use clap::Parser;
@@ -32,29 +32,6 @@
async fn hello_world() -> &'static str {
"hello, world!"
}
macro_rules! axum_box_after_every_route {
(Router::new()
$(.nest($nest_path:expr, $nest_svc:expr$(,)?))*
$(.route($route_path:expr, $route_svc:expr$(,)?))*
) => {
Router::new()
$(
.nest($nest_path, $nest_svc)
.boxed()
)*
$(
.route($route_path, $route_svc)
.boxed()
)*
};
}
pub(crate) use axum_box_after_every_route;
#[tokio::main]
#[allow(clippy::semicolon_if_nothing_returned)]
@@ -12,25 +12,13 @@
mod yank;
use axum::{
body::{Body, BoxBody},
handler::{delete, get, put},
http::{Request, Response},
routing::{delete, get, put},
Router,
};
use futures::future::Future;
use std::convert::Infallible;
pub fn routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new()
pub fn routes() -> Router {
Router::new()
.route("/crates/new", put(publish::handle))
.route("/crates/:crate/owners", get(owners::handle_get))
@@ -38,5 +26,5 @@
.route("/crates/:crate/:version/yank", delete(yank::handle_yank))
.route("/crates/:crate/:version/unyank", put(yank::handle_unyank))
.route("/crates/:crate/:version/download", get(download::handle)))
.route("/crates/:crate/:version/download", get(download::handle))
}
@@ -5,41 +5,23 @@
mod users;
use axum::{
body::{Body, BoxBody},
handler::{delete, get, put},
http::{Request, Response},
routing::{delete, get},
Router,
};
use futures::future::Future;
use std::convert::Infallible;
pub fn authenticated_routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new()
pub fn authenticated_routes() -> Router {
Router::new()
.nest("/organisations", organisations::routes())
.nest("/crates", crates::routes())
.nest("/users", users::routes())
.nest("/auth", auth::authenticated_routes())
.route("/ssh-key", get(ssh_key::handle_get))
.route("/ssh-key", put(ssh_key::handle_put))
.route("/ssh-key/:id", delete(ssh_key::handle_delete)))
.route(
"/ssh-key",
get(ssh_key::handle_get).put(ssh_key::handle_put),
)
.route("/ssh-key/:id", delete(ssh_key::handle_delete))
}
pub fn unauthenticated_routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new().nest("/auth", auth::unauthenticated_routes()))
pub fn unauthenticated_routes() -> Router {
Router::new().nest("/auth", auth::unauthenticated_routes())
}
@@ -1,8 +1,6 @@
use axum::{
body::{Body, BoxBody},
extract,
handler::{get, post},
http::{Request, Response},
routing::{get, post},
Router,
};
use chartered_db::{
@@ -10,41 +8,24 @@
uuid::Uuid,
ConnectionPool,
};
use futures::future::Future;
use serde::Serialize;
use std::convert::Infallible;
pub mod logout;
pub mod openid;
pub mod password;
pub fn authenticated_routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new().route("/logout", get(logout::handle)))
pub fn authenticated_routes() -> Router {
Router::new().route("/logout", get(logout::handle))
}
pub fn unauthenticated_routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new()
pub fn unauthenticated_routes() -> Router {
Router::new()
.route("/register/password", post(password::handle_register))
.route("/login/password", post(password::handle_login))
.route("/login/oauth/:provider/begin", get(openid::begin_oidc))
.route("/login/oauth/complete", get(openid::complete_oidc))
.route("/login/oauth/providers", get(openid::list_providers)))
.route("/login/oauth/providers", get(openid::list_providers))
}
#[derive(Serialize)]
@@ -5,32 +5,20 @@
mod recently_updated;
mod search;
use axum::{
body::{Body, BoxBody},
handler::{delete, get, patch, put},
http::{Request, Response},
Router,
};
use futures::future::Future;
use std::convert::Infallible;
use axum::{routing::get, Router};
pub fn routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new()
pub fn routes() -> Router {
Router::new()
.route("/:org/:crate", get(info::handle))
.route("/:org/:crate/members", get(members::handle_get))
.route("/:org/:crate/members", patch(members::handle_patch))
.route("/:org/:crate/members", put(members::handle_put))
.route("/:org/:crate/members", delete(members::handle_delete))
.route(
"/:org/:crate/members",
get(members::handle_get)
.patch(members::handle_patch)
.put(members::handle_put)
.delete(members::handle_delete),
)
.route("/recently-updated", get(recently_updated::handle))
.route("/recently-created", get(recently_created::handle))
.route("/most-downloaded", get(most_downloaded::handle))
.route("/search", get(search::handle)))
.route("/search", get(search::handle))
}
@@ -1,31 +1,21 @@
mod crud;
mod info;
mod list;
mod members;
use axum::{
body::{Body, BoxBody},
handler::{delete, get, patch, put},
http::{Request, Response},
routing::{get, patch},
Router,
};
use futures::future::Future;
use std::convert::Infallible;
pub fn routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new()
.route("/", get(list::handle_get))
.route("/", put(crud::handle_put))
pub fn routes() -> Router {
Router::new()
.route("/", get(list::handle_get).put(crud::handle_put))
.route("/:org", get(info::handle_get))
.route("/:org/members", patch(members::handle_patch))
.route("/:org/members", put(members::handle_put))
.route("/:org/members", delete(members::handle_delete)))
.route(
"/:org/members",
patch(members::handle_patch)
.put(members::handle_put)
.delete(members::handle_delete),
)
}
@@ -1,25 +1,10 @@
mod info;
mod search;
use axum::{
body::{Body, BoxBody},
handler::get,
http::{Request, Response},
Router,
};
use futures::future::Future;
use std::convert::Infallible;
use axum::{routing::get, Router};
pub fn routes() -> Router<
impl tower::Service<
Request<Body>,
Response = Response<BoxBody>,
Error = Infallible,
Future = impl Future<Output = Result<Response<BoxBody>, Infallible>> + Send,
> + Clone
+ Send,
> {
crate::axum_box_after_every_route!(Router::new()
pub fn routes() -> Router {
Router::new()
.route("/search", get(search::handle))
.route("/info/:uuid", get(info::handle)))
.route("/info/:uuid", get(info::handle))
}