Skip to content

feat: Add AnyInitializer to minimize boilerplate for initializers - #475

Merged
spencewenski merged 2 commits into
mainfrom
gh-473-any-initializer
Oct 21, 2024
Merged

spencewenski merged 2 commits into
mainfrom
gh-473-any-initializer

Conversation

@spencewenski

@spencewenski spencewenski commented Oct 21, 2024 •

Copy link
Copy Markdown
Member

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
@codecov

codecov Bot commented Oct 21, 2024 •

Copy link
Copy Markdown

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
@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