Skip to content

Commit a85b439

Browse files
committed
feat: upgrade axum to 0.8.1 and related dependencies
Signed-off-by: JmPotato <github@ipotato.me>
1 parent 156cf5b commit a85b439

File tree

6 files changed

+16
-23
lines changed

6 files changed

+16
-23
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
axum = "0.7.5"
7+
async-trait = "0.1.87"
8+
axum = "0.8.1"
89
axum-extra = "0.9.3"
9-
axum-login = "0.16.0"
10+
axum-login = { version = "0.17.0" }
1011
chrono = { version = "0.4.38", features = ["serde"] }
1112
comrak = { version = "0.28.0", features = ["syntect"] }
1213
minijinja = { version = "2.2.0", features = ["loader"] }
@@ -24,7 +25,7 @@ thiserror = "1.0.63"
2425
tokio = { version = "1.40.0", features = ["full"] }
2526
toml = "0.8.19"
2627
tower-http = { version = "0.5.2", features = ["fs", "trace"] }
27-
tower-sessions = { version = "0.13.0", default-features = false, features = [
28+
tower-sessions = { version = "0.14.0", default-features = false, features = [
2829
"signed",
2930
] }
3031
tracing = "0.1.40"

src/app.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,14 @@ impl App {
215215
.route("/change_password", post(handler_change_pw_post))
216216
.route("/edit/article/new", get(handler_edit_article_get))
217217
.route("/edit/article/new", post(handler_edit_post::<Article>))
218-
.route("/edit/article/:id", get(handler_edit_article_get))
219-
.route("/edit/article/:id", post(handler_edit_post::<Article>))
220-
.route("/delete/article/:id", get(handler_delete_post::<Article>))
218+
.route("/edit/article/{id}", get(handler_edit_article_get))
219+
.route("/edit/article/{id}", post(handler_edit_post::<Article>))
220+
.route("/delete/article/{id}", get(handler_delete_post::<Article>))
221221
.route("/edit/page/new", get(handler_edit_page_get))
222222
.route("/edit/page/new", post(handler_edit_post::<Page>))
223-
.route("/edit/page/:id", get(handler_edit_page_get))
224-
.route("/edit/page/:id", post(handler_edit_post::<Page>))
225-
.route("/delete/page/:id", get(handler_delete_post::<Page>))
223+
.route("/edit/page/{id}", get(handler_edit_page_get))
224+
.route("/edit/page/{id}", post(handler_edit_post::<Page>))
225+
.route("/delete/page/{id}", get(handler_delete_post::<Page>))
226226
.route_layer(login_required!(AppState, login_url = "/login"));
227227

228228
let app = Router::new()
@@ -231,14 +231,14 @@ impl App {
231231
.nest_service("/static", ServeDir::new(STATIC_DIR))
232232
// serve the page handlers
233233
.route("/", get(handler_home))
234-
.route("/page/:num", get(handler_page))
235-
.route("/article/:id_or_slug", get(handler_article))
234+
.route("/page/{num}", get(handler_page))
235+
.route("/article/{id_or_slug}", get(handler_article))
236236
.route("/articles", get(handler_articles))
237-
.route("/tag/:tag", get(handler_tag))
237+
.route("/tag/{tag}", get(handler_tag))
238238
.route("/tags", get(handler_tags))
239239
.route("/feed", get(handler_feed))
240240
.route("/ping", get(handler_ping))
241-
.route("/:page", get(handler_custom_page))
241+
.route("/{page}", get(handler_custom_page))
242242
.route("/login", get(handler_login_get))
243243
.route("/login", post(handler_login_post))
244244
.route("/logout", get(handler_logout))

src/auth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use axum::async_trait;
1+
use async_trait::async_trait;
22
use axum_login::{AuthUser, AuthnBackend, UserId};
33
use serde::Deserialize;
44
use tokio::task;
@@ -36,7 +36,7 @@ impl AuthnBackend for AppState {
3636
) -> Result<Option<Self::User>, Self::Error> {
3737
let user = User::get_by_username(&self.db, &creds.username).await;
3838
// Verifying the password is blocking and potentially slow, so we'll do so via
39-
// `spawn_blocking`.
39+
// `spawn_blocking` so it can be yielded to the runtime.
4040
task::spawn_blocking(|| {
4141
// We're using password-based authentication--this works by comparing our form
4242
// input with an argon2 password hash.

src/models/articles.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::fmt::{self, Display};
22

3-
use axum::async_trait;
43
use chrono::{DateTime, Utc};
54
use serde::{Deserialize, Serialize};
65
use sqlx::prelude::FromRow;
@@ -110,7 +109,6 @@ impl Display for Article {
110109
}
111110
}
112111

113-
#[async_trait]
114112
impl Editable for Article {
115113
fn get_redirect_url(&self) -> String {
116114
if !self.slug.is_empty() {

src/models/pages.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::fmt::{self, Display};
22

3-
use axum::async_trait;
43
use chrono::{DateTime, Utc};
54
use serde::{Deserialize, Serialize};
65
use sqlx::prelude::FromRow;
@@ -78,7 +77,6 @@ impl Display for Page {
7877
}
7978
}
8079

81-
#[async_trait]
8280
impl Editable for Page {
8381
fn get_redirect_url(&self) -> String {
8482
format!("/{}", self.title.to_lowercase())

src/utils.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::{collections::HashSet, fmt::Display, sync::Arc};
22

33
use axum::{
4-
async_trait,
54
extract::{rejection::PathRejection, FromRef, FromRequest, FromRequestParts, Request},
65
http::request::Parts,
76
response::Html,
@@ -27,7 +26,6 @@ macro_rules! render_template_with_context {
2726
// A wrapper for `axum::extract::Path` that can render a 404 page if the path is rejected.
2827
pub struct Path<T>(pub T);
2928

30-
#[async_trait]
3129
impl<S, T> FromRequestParts<S> for Path<T>
3230
where
3331
Arc<AppState>: FromRef<S>,
@@ -73,7 +71,6 @@ pub struct EditorForm {
7371
pub content: Option<String>,
7472
}
7573

76-
#[async_trait]
7774
pub trait Editable: DeserializeOwned + Display {
7875
fn get_redirect_url(&self) -> String;
7976
async fn update(&self, db: &sqlx::MySqlPool) -> Result<Self, Error>;
@@ -86,7 +83,6 @@ pub struct Entity<T> {
8683
pub is_new: bool,
8784
}
8885

89-
#[async_trait]
9086
impl<S, T> FromRequest<S> for Entity<T>
9187
where
9288
Arc<AppState>: FromRef<S>,

0 commit comments

Comments
 (0)