Replace Rocket and Tera with Rouille and Maud #88

Merged
glyph merged 67 commits from rouille_maud into main 2022-03-25 08:07:15 +00:00
Owner

Context

After spending the better part of two weeks trying to get the Rocket + Tera version of peach-web to compile, I eventually gave up and decided it was a better use of my time to simply complete the refactor. I did this as a last resort.

Having more-or-less completed the refactor, I'm happy to report that the Rouille + Maud version reduces total build-time dependencies by approximately 200 (that means it's roughly 40% lighter). I'm able to compile a release build on my Pi 3 B+ in 30 minutes; I'm really happy with that, especially considering I wasn't able to compile the previous version at all. The compiled binary is less than 25% of the size of the previous version (4.3 MB when stripped). When running on my Pi, peach-web uses 0.0 % CPU and 0.1 % RAM.

Changes

The layout of the code has changed to reflect the different approach of Rouille and Maud.

We now have a one-file-per-route architecture, with each file containing a template builder and (sometimes) a form handler. Routes are located in src/routes, common templates are located in src/templates and utilities are located in /src/utils. All sbot interactions have been moved to src/utils/sbot.rs.

The application has two routers: one with publically-accessible routes (/src/public_router.rs) and one with routes which require the visitor to be authenticated (/src/private_router.rs).

Configuration has been moved from Rocket.toml to environment variables (DISABLE_AUTH, STANDALONE_MODE, ADDR, PORT). Default values are assigned when the program starts and are only updated if the the environment variables are set.

Remaining Work

I have not implemented all the changes required to have the complete version working (ie. not PeachPub but PeachCloud). I will do that in the weeks and months to come. I also need to convert all the old Rocket-specific test code to Rouille.

## Context After spending the better part of two weeks trying to get the Rocket + Tera version of `peach-web` to compile, I eventually gave up and decided it was a better use of my time to simply complete the refactor. I did this as a last resort. Having more-or-less completed the refactor, I'm happy to report that the [Rouille](https://crates.io/crates/rouille) + [Maud](https://maud.lambda.xyz/) version reduces total build-time dependencies by approximately 200 (that means it's roughly 40% lighter). I'm able to compile a release build on my Pi 3 B+ in 30 minutes; I'm really happy with that, especially considering I wasn't able to compile the previous version at all. The compiled binary is less than 25% of the size of the previous version (4.3 MB when stripped). When running on my Pi, `peach-web` uses 0.0 % CPU and 0.1 % RAM. ## Changes The layout of the code has changed to reflect the different approach of Rouille and Maud. We now have a one-file-per-route architecture, with each file containing a template builder and (sometimes) a form handler. Routes are located in `src/routes`, common templates are located in `src/templates` and utilities are located in `/src/utils`. All sbot interactions have been moved to `src/utils/sbot.rs`. The application has two routers: one with publically-accessible routes (`/src/public_router.rs`) and one with routes which require the visitor to be authenticated (`/src/private_router.rs`). Configuration has been moved from `Rocket.toml` to environment variables (`DISABLE_AUTH`, `STANDALONE_MODE`, `ADDR`, `PORT`). Default values are assigned when the program starts and are only updated if the the environment variables are set. ## Remaining Work I have not implemented all the changes required to have the complete version working (ie. not PeachPub but PeachCloud). I will do that in the weeks and months to come. I also need to convert all the old Rocket-specific test code to Rouille.
glyph added the
refactor
peach-web
peach-lib
labels 2022-03-24 08:05:47 +00:00
glyph added 57 commits 2022-03-24 08:06:03 +00:00
glyph added 2 commits 2022-03-24 11:42:17 +00:00
glyph changed title from Refactor: Replace Rocket and Tera with Rouille and Maud to Replace Rocket and Tera with Rouille and Maud 2022-03-24 17:08:16 +00:00
glyph added 2 commits 2022-03-25 06:43:46 +00:00
glyph added 1 commit 2022-03-25 06:45:18 +00:00
glyph added 2 commits 2022-03-25 07:19:51 +00:00
glyph added 1 commit 2022-03-25 07:26:52 +00:00
glyph added 1 commit 2022-03-25 07:39:14 +00:00
glyph added 1 commit 2022-03-25 08:06:13 +00:00
glyph merged commit fded48908d into main 2022-03-25 08:07:15 +00:00
glyph deleted branch rouille_maud 2022-03-25 08:07:17 +00:00
Sign in to join this conversation.
No description provided.