Skip to content

Migrate to axum#115

Open
lajp wants to merge 30 commits intomainfrom
axum
Open

Migrate to axum#115
lajp wants to merge 30 commits intomainfrom
axum

Conversation

@lajp
Copy link
Member

@lajp lajp commented Oct 24, 2025

No description provided.

@lajp lajp requested a review from DrVilepis as a code owner October 24, 2025 07:37
lajp and others added 6 commits October 24, 2025 09:39
also remove all instances of impl IntoResponse in endpoint types
also thank you utoipa
@Eldemarkki
Copy link
Member

settings.toml.example is missing the new email fields

@Eldemarkki
Copy link
Member

Secured access mentions should be removed from error.rs and APISPEC.md

@Eldemarkki
Copy link
Member

The APISPEC seems to be out of date in general, for example it still has /auth/changepassword endpoint. Maybe the file is not needed now that we have OpenAPI, we could move the descriptions there?

@DrVilepis
Copy link
Member

The plan is to completely remove the apispec in favor of openapi. Also I doubt that the apispec is even 50% correct

DrVilepis
DrVilepis previously approved these changes Dec 17, 2025
Copy link
Member

@DrVilepis DrVilepis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preliminary approval now that the pr is starting to be in its final state.

Copy link
Member Author

@lajp lajp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks almost good to go! I mostly complained about unwrap()s but there's some other comments as well. I did not review tests.

src/api/auth.rs Outdated
type Error = TimeError;
type Future = Pin<Box<dyn Future<Output = actix_web::Result<Self, Self::Error>>>>;
async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Self, Self::Rejection> {
let auth = parts.extensions.get::<Authentication>().cloned().unwrap();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a Self::Rejection instead of unwrap

src/api/auth.rs Outdated
type Error = TimeError;
type Future = Pin<Box<dyn Future<Output = actix_web::Result<Self, Self::Error>>>>;
async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
let auth = parts.extensions.get::<Authentication>().cloned().unwrap();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably also shouldn't panic

src/api/auth.rs Outdated
type Rejection = TimeError;

async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Self, Self::Rejection> {
let auth = parts.extensions.get::<Authentication>().cloned().unwrap();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't panic here either


let token = generate_password_reset_token();

let message = Message::builder()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert these unwraps to .expect("BUG: <description>") if they are truly infallible

src/api/mod.rs Outdated
pub static REGEX: Regex = Regex::new("^[[:word:]]{2,32}$").unwrap();
}
pub static VALID_NAME_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new("^[[:word:]]{2,32}$").unwrap());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to .expect("BUG: failed to compile name regex") or something like that

}

// Wtf is this
fn project_deserialize<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be removed :D

let conn_info = req
.extensions()
.get::<ConnectInfo<SocketAddr>>()
.unwrap()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.expect("BUG: connection info is always available")

headers.insert(
HeaderName::from_static("ratelimit-limit"),
HeaderValue::from_str(&quota.burst_size().to_string())?,
HeaderValue::from_str(&quota.burst_size().to_string()).unwrap(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please .expect all header value creations

Ok(req.into_response(response.map_into_right_body()))
)
.body(Body::empty())
.unwrap())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.expect

Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
.unwrap())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.expect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants