Hirevo / alexandrie

An alternative crate registry, implemented in Rust.
https://hirevo.github.io/alexandrie/
Apache License 2.0
493 stars 55 forks source link

Move to `axum` and `tokio` stack #169

Closed Hirevo closed 1 year ago

Hirevo commented 1 year ago

This PR migrates all of Alexandrie's codebase to use:

which also implies that we now use:

This move allows to remove some async runtime duplication that was existing in Alexandrie due to its use of libraries that always assumed to be running a tokio runtime (like rusoto for interactions with S3).

Although I still find tide to be a very nice web framework, its reliance on async-std makes it a bit annoying to work with and can prevent integrations with other library integrations (like middlewares or frontend frameworks like leptos which I am considering using as a replacement for handlebars templating and flash session data especially for pages with rich interactions like the account management page).

The primary goal of this PR is to keep everything working just like before, and therefore is pretty much a 1-to-1 translation from the old to the new framework.
This means that there may be things that may be significantly improved by using more advanced features of the axum framework, like handling the authentication using the Authorization header in the API, which is implemented a bit naively here.
These improvements will come in subsequent PRs.

Closes #159.

Hirevo commented 1 year ago

The migration to Axum is now complete, and the authorization handling has now been improved through the use of custom Auth extractors (one for the frontend based on server-side sessions, and one for the API based on Cargo tokens in Authorization headers).
After the merging of this PR, all other PRs will have to be significantly updated.
I'll try to do this for the ones that I was working on before starting this migration.