Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add AnyInitializer to minimize boilerplate for initializers #475

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

spencewenski
Copy link
Member

@spencewenski spencewenski commented Oct 21, 2024

If a consumer wants to initialize the Axum Router in a way that's not already supported by Roadster, they need to implement the Initializer trait, which is extra boilerplate that could be annoying.

Add AnyInitializer struct that implements the Initializer trait, so consumers just need to provide the name of the initializer and the logic to build/configure the Axum Router.

Note: This PR also contains a breaking change to AnyMiddleware. However, since this was just released a few hours ago, I doubt anyone is using it yet, so it should be relatively safe to just release the breaking change in a patch update. Actually, it looks like AnyMiddleware wasn't released before this PR was merged, so no api-breaking changes were released.

Closes #473

If a consumer wants to initialize the Axum Router in a way that's not
already supported by Roadster, they need to implement the `Initializer`
trait, which is extra boilerplate that could be annoying.

Add `AnyInitializer` struct that implements the `Initializer` trait, so
consumers just need to provide the name of the initializer and the logic
to build/configure the Axum Router.

Note: This PR also contains a breaking change to `AnyMiddleware`. However,
since this was just released a few hours ago, I doubt anyone is using it
yet, so it should be relatively safe to just release the breaking change
in a patch update.

Closes #473
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 0% with 65 lines in your changes missing coverage. Please review.

Project coverage is 42.25%. Comparing base (7a374cb) to head (af64e60).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/service/http/initializer/any.rs 0.00% 59 Missing ⚠️
src/service/http/builder.rs 0.00% 4 Missing ⚠️
src/service/http/middleware/any.rs 0.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/service/http/initializer/mod.rs 7.69% <ø> (ø)
src/service/http/middleware/any.rs 0.00% <0.00%> (ø)
src/service/http/builder.rs 26.25% <0.00%> (-0.68%) ⬇️
src/service/http/initializer/any.rs 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7a374cb...af64e60. Read the comment docs.

@spencewenski spencewenski merged commit c155402 into main Oct 21, 2024
18 of 19 checks passed
@spencewenski spencewenski deleted the gh-473-any-initializer branch October 21, 2024 21:03
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.

Add AnyInitialize to impl Initializer similar to AnyMiddleware as well
1 participant