Skip to content

Move to axum and tokio stack#169

Merged
Hirevo merged 10 commits intomasterfrom
refactor/axum
Sep 7, 2023
Merged

Move to axum and tokio stack#169
Hirevo merged 10 commits intomasterfrom
refactor/axum

Conversation

@Hirevo
Copy link
Owner

@Hirevo Hirevo commented Aug 19, 2023

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

  • axum instead of tide as its web framework
  • tokio instead of async-std as its main async runtime
  • tracing instead of slog as the logging mechanism
  • tower as the mean to implement middlewares (called layers)

which also implies that we now use:

  • http instead of http-types as its HTTP type definitions
  • hyper instead of async-h1 as its HTTP parser implementation

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 Hirevo added P-medium Priority: Medium M-frontend Module: Frontend M-api Module: Programmatic API C-refactor Category: Refactor labels Aug 19, 2023
@Hirevo Hirevo self-assigned this Aug 19, 2023
@Hirevo
Copy link
Owner Author

Hirevo commented Sep 7, 2023

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.

@Hirevo Hirevo merged commit 9a6c637 into master Sep 7, 2023
@Hirevo Hirevo deleted the refactor/axum branch September 7, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-refactor Category: Refactor M-api Module: Programmatic API M-frontend Module: Frontend P-medium Priority: Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider switching to tokio/axum/hyper stack

1 participant