From 99ff9cdc6890959cd4d2112c2e37b97ae83cb43c Mon Sep 17 00:00:00 2001 From: Vika Date: Sun, 9 Jul 2023 22:22:34 +0300 Subject: cargo update, part 2: Axum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Axum got some breaking changes and gained some nice features — however, features come later, breaking changes come first. Perhaps it would be nice to actually construct a State with all of my stuff, and then make functions generic over that. Could reduce the amount of generic stuff I am producing... maybe. --- kittybox-rs/Cargo.lock | 200 ++++++++++++++++++++------------- kittybox-rs/Cargo.toml | 6 +- kittybox-rs/indieauth/Cargo.toml | 2 +- kittybox-rs/src/frontend/onboarding.rs | 4 +- kittybox-rs/src/indieauth/mod.rs | 37 +++--- kittybox-rs/src/media/mod.rs | 4 +- kittybox-rs/src/micropub/mod.rs | 10 +- kittybox-rs/src/webmentions/mod.rs | 2 +- kittybox-rs/templates/Cargo.toml | 2 +- kittybox-rs/util/Cargo.toml | 2 +- 10 files changed, 158 insertions(+), 111 deletions(-) (limited to 'kittybox-rs') diff --git a/kittybox-rs/Cargo.lock b/kittybox-rs/Cargo.lock index 1c3f5d4..39323f4 100644 --- a/kittybox-rs/Cargo.lock +++ b/kittybox-rs/Cargo.lock @@ -257,12 +257,13 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.5.17" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acee9fd5073ab6b045a275b3e709c163dd36c90685219cb21804a147b58dba43" +checksum = "f8175979259124331c1d7bf6586ee7e0da434155e4b2d48ec2c8386281d8df39" dependencies = [ "async-trait", "axum-core", + "axum-macros", "bitflags 1.3.2", "bytes", "futures-util", @@ -277,22 +278,23 @@ dependencies = [ "multer", "percent-encoding", "pin-project-lite", + "rustversion", "serde", "serde_json", + "serde_path_to_error", "serde_urlencoded", "sync_wrapper", "tokio", "tower", - "tower-http", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.2.9" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37e5939e02c56fecd5c017c37df4238c0a839fa76b7f97acdd7efb804fd181cc" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", "bytes", @@ -300,30 +302,46 @@ dependencies = [ "http", "http-body", "mime", + "rustversion", "tower-layer", "tower-service", ] [[package]] name = "axum-extra" -version = "0.3.7" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69034b3b0fd97923eee2ce8a47540edb21e07f48f87f67d44bb4271cec622bdb" +checksum = "febf23ab04509bd7672e6abe76bd8277af31b679e89fa5ffc6087dc289a448a3" dependencies = [ "axum", + "axum-core", "bytes", "cookie", "futures-util", "http", + "http-body", "mime", "pin-project-lite", + "serde", "tokio", "tower", - "tower-http", + "tower-http 0.4.1", "tower-layer", "tower-service", ] +[[package]] +name = "axum-macros" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bb524613be645939e280b7279f7b017f98cf7f5ef084ec374df373530e73277" +dependencies = [ + "heck", + "proc-macro2 1.0.64", + "quote 1.0.29", + "syn 2.0.25", +] + [[package]] name = "backtrace" version = "0.3.68" @@ -389,16 +407,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array", + "digest", ] [[package]] @@ -587,9 +596,9 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.16.2" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" dependencies = [ "percent-encoding", "time 0.3.23", @@ -612,6 +621,15 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + [[package]] name = "cpufeatures" version = "0.2.9" @@ -701,6 +719,12 @@ dependencies = [ "syn 2.0.25", ] +[[package]] +name = "dary_heap" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7762d17f1241643615821a8455a0b2c3e803784b058693d990b11f2dce25a0ca" + [[package]] name = "data-encoding" version = "2.4.0" @@ -770,22 +794,13 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c1bba4f227a4a53d12b653f50ca7bf10c9119ae2aba56aff9e0338b5c98f36a" -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array", -] - [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer 0.10.4", + "block-buffer", "const-oid", "crypto-common", "subtle", @@ -1192,6 +1207,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.14.0" @@ -1272,7 +1296,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] @@ -1606,7 +1630,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "serde_variant", - "sha2 0.9.9", + "sha2", "sqlx", "tempfile", "thiserror", @@ -1614,7 +1638,7 @@ dependencies = [ "tokio-stream", "tokio-util", "tower", - "tower-http", + "tower-http 0.3.5", "tracing", "tracing-log", "tracing-subscriber", @@ -1657,7 +1681,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sha2 0.9.9", + "sha2", "url", ] @@ -1706,21 +1730,25 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "libflate" -version = "1.4.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ff4ae71b685bbad2f2f391fe74f6b7659a34871c08b210fdc039e43bee07d18" +checksum = "9f7d5654ae1795afc7ff76f4365c2c8791b0feb18e8996a96adad8ffd7c3b2bf" dependencies = [ "adler32", + "core2", "crc32fast", + "dary_heap", "libflate_lz77", ] [[package]] name = "libflate_lz77" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a52d3a8bfc85f250440e4424db7d857e241a3aebbbe301f3eb606ab15c39acbf" +checksum = "be5f52fb8c451576ec6b79d3f4deb327398bc05bbdbd99021a6e77a4c855d524" dependencies = [ + "core2", + "hashbrown 0.13.2", "rle-decode-fast", ] @@ -1803,19 +1831,19 @@ dependencies = [ [[package]] name = "markup" -version = "0.12.5" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e56549270844a0e513d26db15562a783dd282e351baec8650c6f4c1bcaee54ef" +checksum = "bd9196a235d499738d04f6a2466ce2610bf6b84730610efea8bee1b90d028b0d" dependencies = [ - "itoa 0.4.8", + "itoa 1.0.8", "markup-proc-macro", ] [[package]] name = "markup-proc-macro" -version = "0.12.5" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5948a1826d7a5ba7c550ff109894bca69b6db05ea72215f2e7d1a929b755f932" +checksum = "1a927f0e237dcbdd8c1a8ab03c4e1e8b1999804c448ebf06ff3b5512506c8150" dependencies = [ "proc-macro2 1.0.64", "quote 1.0.29", @@ -1869,9 +1897,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matchit" -version = "0.5.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73cbba799671b762df5a175adf59ce145165747bb891505c43d09aefbbf38beb" +checksum = "b87248edafb776e59e6ee64a79086f65890d3510f2c656c000bf2a7e8a0aea40" [[package]] name = "md-5" @@ -1879,7 +1907,7 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6365506850d44bff6e2fbcb5176cf63650e48bd45ef2fe2665ae1570e0f4b9ca" dependencies = [ - "digest 0.10.7", + "digest", ] [[package]] @@ -2104,12 +2132,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - [[package]] name = "openssl" version = "0.10.55" @@ -2836,7 +2858,7 @@ checksum = "6ab43bb47d23c1a631b4b680199a45255dce26fa9ab2fa902581f624ff13e6a8" dependencies = [ "byteorder", "const-oid", - "digest 0.10.7", + "digest", "num-bigint-dig", "num-integer", "num-iter", @@ -2956,6 +2978,12 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" + [[package]] name = "ryu" version = "1.0.14" @@ -3047,9 +3075,9 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.169" +version = "1.0.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd51c3db8f9500d531e6c12dd0fd4ad13d133e9117f5aebac3cdbb8b6d9824b0" +checksum = "a56657f512baabca8f840542f9ca8152aecf182c473c26e46e58d6aab4f6e439" dependencies = [ "serde_derive", ] @@ -3066,9 +3094,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.169" +version = "1.0.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27738cfea0d944ab72c3ed01f3d5f23ec4322af8a1431e40ce630e4c01ea74fd" +checksum = "77d477848e6b23adba0db397777d5aad864555bc17fd9c89abb3b8009788b7b8" dependencies = [ "proc-macro2 1.0.64", "quote 1.0.29", @@ -3086,6 +3114,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc4422959dd87a76cb117c191dcbffc20467f06c9100b76721dab370f24d3a" +dependencies = [ + "itoa 1.0.8", + "serde", +] + [[package]] name = "serde_qs" version = "0.8.5" @@ -3145,7 +3183,7 @@ checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -3154,19 +3192,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "sha2" version = "0.10.7" @@ -3175,7 +3200,7 @@ checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -3202,7 +3227,7 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" dependencies = [ - "digest 0.10.7", + "digest", "rand_core 0.6.4", ] @@ -3326,7 +3351,7 @@ dependencies = [ "rustls-pemfile", "serde", "serde_json", - "sha2 0.10.7", + "sha2", "smallvec", "sqlformat", "thiserror", @@ -3366,7 +3391,7 @@ dependencies = [ "quote 1.0.29", "serde", "serde_json", - "sha2 0.10.7", + "sha2", "sqlx-core", "sqlx-mysql", "sqlx-postgres", @@ -3390,7 +3415,7 @@ dependencies = [ "bytes", "chrono", "crc", - "digest 0.10.7", + "digest", "dotenvy", "either", "futures-channel", @@ -3411,7 +3436,7 @@ dependencies = [ "rsa", "serde", "sha1 0.10.5", - "sha2 0.10.7", + "sha2", "smallvec", "sqlx-core", "stringprep", @@ -3452,7 +3477,7 @@ dependencies = [ "serde", "serde_json", "sha1 0.10.5", - "sha2 0.10.7", + "sha2", "smallvec", "sqlx-core", "stringprep", @@ -3846,12 +3871,29 @@ dependencies = [ "http-body", "http-range-header", "pin-project-lite", - "tower", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "tower-http" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8bd22a874a2d0b70452d5597b12c537331d49060824a95f49f108994f94aa4c" +dependencies = [ + "bitflags 2.3.3", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-layer" version = "0.3.2" diff --git a/kittybox-rs/Cargo.toml b/kittybox-rs/Cargo.toml index 1175828..71ebc66 100644 --- a/kittybox-rs/Cargo.toml +++ b/kittybox-rs/Cargo.toml @@ -114,10 +114,10 @@ features = ["io-util"] version = "^1.0.42" optional = true [dependencies.axum] -version = "^0.5.11" -features = ["multipart", "json", "headers", "form"] +version = "^0.6.18" +features = ["multipart", "json", "headers", "form", "macros"] [dependencies.axum-extra] -version = "^0.3.7" +version = "^0.7.4" features = ["cookie"] [dependencies.chrono] # Date and time library for Rust version = "^0.4.19" diff --git a/kittybox-rs/indieauth/Cargo.toml b/kittybox-rs/indieauth/Cargo.toml index 332584d..d6bc1fe 100644 --- a/kittybox-rs/indieauth/Cargo.toml +++ b/kittybox-rs/indieauth/Cargo.toml @@ -21,7 +21,7 @@ features = ["serde"] version = "^1.0.170" features = ["derive"] [dependencies.axum-core] -version = "^0.2.6" +version = "^0.3.4" optional = true [dependencies.serde_json] version = "^1.0.64" diff --git a/kittybox-rs/src/frontend/onboarding.rs b/kittybox-rs/src/frontend/onboarding.rs index 4b62d87..d5cde02 100644 --- a/kittybox-rs/src/frontend/onboarding.rs +++ b/kittybox-rs/src/frontend/onboarding.rs @@ -129,8 +129,8 @@ async fn onboard( pub async fn post( Extension(db): Extension, Host(host): Host, - Json(data): Json, Extension(http): Extension, + Json(data): Json, ) -> axum::response::Response { let user_uid = format!("https://{}/", host.as_str()); @@ -166,6 +166,6 @@ pub async fn post( pub fn router(database: S, http: reqwest::Client) -> axum::routing::MethodRouter { axum::routing::get(get) .post(post::) - .layer(axum::Extension(database)) + .layer::<_, _, std::convert::Infallible>(axum::Extension(database)) .layer(axum::Extension(http)) } diff --git a/kittybox-rs/src/indieauth/mod.rs b/kittybox-rs/src/indieauth/mod.rs index a86100d..0ad2702 100644 --- a/kittybox-rs/src/indieauth/mod.rs +++ b/kittybox-rs/src/indieauth/mod.rs @@ -73,20 +73,20 @@ impl axum::response::IntoResponse for IndieAuthResourceError { } #[async_trait::async_trait] -impl axum::extract::FromRequest for User { +impl axum::extract::FromRequestParts for User { type Rejection = IndieAuthResourceError; - async fn from_request(req: &mut axum::extract::RequestParts) -> Result { + async fn from_request_parts(req: &mut axum::http::request::Parts, state: &S) -> Result { let TypedHeader(Authorization(token)) = - TypedHeader::>::from_request(req) + TypedHeader::>::from_request_parts(req, state) .await .map_err(|_| IndieAuthResourceError::Unauthorized)?; - let axum::Extension(auth) = axum::Extension::::from_request(req) + let axum::Extension(auth) = axum::Extension::::from_request_parts(req, state) .await .unwrap(); - let Host(host) = Host::from_request(req) + let Host(host) = Host::from_request_parts(req, state) .await .map_err(|_| IndieAuthResourceError::InvalidRequest)?; @@ -253,9 +253,9 @@ async fn verify_credential( #[tracing::instrument(skip(backend, confirmation))] async fn authorization_endpoint_confirm( Host(host): Host, - Json(confirmation): Json, Extension(backend): Extension, cookies: CookieJar, + Json(confirmation): Json, ) -> Response { tracing::debug!("Received authorization confirmation from user"); #[cfg(feature = "webauthn")] @@ -318,11 +318,12 @@ async fn authorization_endpoint_confirm( .into_response() } +#[tracing::instrument(skip(backend, db))] async fn authorization_endpoint_post( Host(host): Host, - Form(grant): Form, Extension(backend): Extension, - Extension(db): Extension + Extension(db): Extension, + Form(grant): Form, ) -> Response { match grant { GrantRequest::AuthorizationCode { @@ -373,9 +374,9 @@ async fn authorization_endpoint_post( error_uri: None }.into_response() } - let profile = if dbg!(request.scope.as_ref() + let profile = if request.scope.as_ref() .map(|s| s.has(&Scope::Profile)) - .unwrap_or_default()) + .unwrap_or_default() { match get_profile( db, @@ -384,7 +385,10 @@ async fn authorization_endpoint_post( .map(|s| s.has(&Scope::Email)) .unwrap_or_default() ).await { - Ok(profile) => dbg!(profile), + Ok(profile) => { + tracing::debug!("Retrieved profile: {:?}", profile); + profile + }, Err(err) => { tracing::error!("Error retrieving profile from database: {}", err); @@ -408,9 +412,9 @@ async fn authorization_endpoint_post( #[tracing::instrument(skip(backend, db))] async fn token_endpoint_post( Host(host): Host, - Form(grant): Form, Extension(backend): Extension, - Extension(db): Extension + Extension(db): Extension, + Form(grant): Form, ) -> Response { #[inline] fn prepare_access_token(me: url::Url, client_id: url::Url, scope: Scopes) -> TokenData { @@ -655,11 +659,12 @@ async fn token_endpoint_post( } } +#[tracing::instrument(skip(backend, token_request))] async fn introspection_endpoint_post( Host(host): Host, - Form(token_request): Form, TypedHeader(Authorization(auth_token)): TypedHeader>, - Extension(backend): Extension + Extension(backend): Extension, + Form(token_request): Form, ) -> Response { use serde_json::json; @@ -693,8 +698,8 @@ async fn introspection_endpoint_post( async fn revocation_endpoint_post( Host(host): Host, + Extension(backend): Extension, Form(revocation): Form, - Extension(backend): Extension ) -> impl IntoResponse { let me: url::Url = format!("https://{}/", host).parse().unwrap(); diff --git a/kittybox-rs/src/media/mod.rs b/kittybox-rs/src/media/mod.rs index 297184a..71f875e 100644 --- a/kittybox-rs/src/media/mod.rs +++ b/kittybox-rs/src/media/mod.rs @@ -25,9 +25,9 @@ impl From for MicropubError { #[tracing::instrument(skip(blobstore))] pub(crate) async fn upload( - mut upload: Multipart, Extension(blobstore): Extension, - user: User + user: User, + mut upload: Multipart ) -> Response { if !user.check_scope(&Scope::Media) { return MicropubError { diff --git a/kittybox-rs/src/micropub/mod.rs b/kittybox-rs/src/micropub/mod.rs index 9351603..04bf0a5 100644 --- a/kittybox-rs/src/micropub/mod.rs +++ b/kittybox-rs/src/micropub/mod.rs @@ -497,9 +497,9 @@ async fn dispatch_body( pub(crate) async fn post( Extension(db): Extension, Extension(http): Extension, + TypedHeader(content_type): TypedHeader, user: User, body: BodyStream, - TypedHeader(content_type): TypedHeader, ) -> axum::response::Response { match dispatch_body(body, content_type).await { Ok(PostBody::Action(action)) => match post_action(action, db, user).await { @@ -639,15 +639,15 @@ where { axum::routing::get(query::) .post(post::) - .layer(tower_http::cors::CorsLayer::new() + .layer::<_, _, std::convert::Infallible>(tower_http::cors::CorsLayer::new() .allow_methods([ axum::http::Method::GET, axum::http::Method::POST, ]) .allow_origin(tower_http::cors::Any)) - .layer(axum::Extension(storage)) - .layer(axum::Extension(http)) - .layer(axum::Extension(auth)) + .layer::<_, _, std::convert::Infallible>(axum::Extension(storage)) + .layer::<_, _, std::convert::Infallible>(axum::Extension(http)) + .layer::<_, _, std::convert::Infallible>(axum::Extension(auth)) } #[cfg(test)] diff --git a/kittybox-rs/src/webmentions/mod.rs b/kittybox-rs/src/webmentions/mod.rs index 630a1a6..becddbc 100644 --- a/kittybox-rs/src/webmentions/mod.rs +++ b/kittybox-rs/src/webmentions/mod.rs @@ -18,8 +18,8 @@ impl queue::PostgresJobItem for Webmention { } async fn accept_webmention>( + Extension(queue): Extension, Form(webmention): Form, - Extension(queue): Extension ) -> Response { if let Err(err) = webmention.source.parse::() { return (StatusCode::BAD_REQUEST, err.to_string()).into_response() diff --git a/kittybox-rs/templates/Cargo.toml b/kittybox-rs/templates/Cargo.toml index fb123f4..38e73b3 100644 --- a/kittybox-rs/templates/Cargo.toml +++ b/kittybox-rs/templates/Cargo.toml @@ -21,7 +21,7 @@ http = "^0.2.7" markup = "^0.13.1" serde_json = "^1.0.64" include_dir = "^0.7.2" -axum = "^0.5.16" +axum = "^0.6.18" [dependencies.chrono] version = "^0.4.19" features = ["serde"] diff --git a/kittybox-rs/util/Cargo.toml b/kittybox-rs/util/Cargo.toml index 23f3abd..0425849 100644 --- a/kittybox-rs/util/Cargo.toml +++ b/kittybox-rs/util/Cargo.toml @@ -11,7 +11,7 @@ fs = ["rand", "tokio", "tokio/fs"] [dependencies] serde = { version = "^1.0.170", features = ["derive"] } serde_json = "^1.0.64" -axum-core = "^0.2.6" +axum-core = "^0.3.4" http = "^0.2.7" async-trait = "^0.1.50" futures-util = "^0.3.14" -- cgit 1.4.1