Skip to content

feat: Add AnyMiddleware to minimize boilerplate for Axum middleware - #472

Merged
spencewenski merged 1 commit into
mainfrom
gh-470-generic-middleware
Oct 21, 2024
Merged

feat: Add AnyMiddleware to minimize boilerplate for Axum middleware#472
spencewenski merged 1 commit into
mainfrom
gh-470-generic-middleware

Conversation

@spencewenski

@spencewenski spencewenski commented Oct 21, 2024

Copy link
Copy Markdown
Member

If a consumer wants to use a middleware that's not already supported by Roadster, they need to implement the Middleware trait, which is extra boilerplate that could be annoying.

Add AnyMiddleware struct that implements the Middleware trait, so consumers just need to provide the name of the middleware and the logic to build/configure it.

Also fixes issue of incorrect feature name used in cfg_if block to enable yaml config files.

Closes #470

If a consumer wants to use a middleware that's not already supported by
Roadster, they need to implement the `Middleware` trait, which is extra
boilerplate that could be annoying.

Add `AnyMiddleware` struct that implements the `Middleware` trait, so
consumers just need to provide the name of the middleware and the logic
to build/configure it.

Closes #470
@codecov

codecov Bot commented Oct 21, 2024

Copy link
Copy Markdown

Codecov Report

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

Project coverage is 42.76%. Comparing base (e86381e) to head (1786bf8).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/service/http/middleware/any.rs 0.00% 44 Missing ⚠️
Files with missing lines Coverage Δ
src/config/mod.rs 32.28% <ø> (ø)
src/config/service/http/middleware.rs 100.00% <ø> (ø)
src/service/http/middleware/mod.rs 100.00% <ø> (ø)
src/service/http/middleware/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 e86381e...1786bf8. Read the comment docs.

@spencewenski
spencewenski merged commit b3b4455 into main Oct 21, 2024
@spencewenski
spencewenski deleted the gh-470-generic-middleware branch October 21, 2024 08:24
@github-actions github-actions Bot mentioned this pull request Oct 21, 2024
spencewenski added a commit that referenced this pull request Oct 21, 2024
## 🤖 New release
* `roadster`: 0.6.13 -> 0.6.14 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.6.14](roadster-v0.6.13...roadster-v0.6.14)
- 2024-10-21

### Added

- Add `AnyMiddleware` to minimize boilerplate for Axum middleware
([#472](#472))

### Other

- A couple minor fixes for the loco comparison
([#471](#471))
- Update book favicon color
([#469](#469))
- Update Roadster features index.md
([#467](#467))
- Update links in getting started index
([#466](#466))
- Add leptos-0.7 example
([#465](#465))
- Update doc test log group name in feature powerset workflow
([#464](#464))
- Add links to relevant docs.rs links in book chapters
([#463](#463))
- Add Leptos comparison
([#462](#462))
- Add utility to generate the feature "powerset" list
([#454](#454))
- Update openapi features in loco comparison
([#452](#452))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Spencer Ferris <3319370+spencewenski@users.noreply.github.com>
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.

Generic/catch-all Middleware for any axum/tower middleware/layer

1 participant