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

Integration hooks for middleware #709

Closed
matthewp opened this issue Sep 19, 2023 · 4 comments
Closed

Integration hooks for middleware #709

matthewp opened this issue Sep 19, 2023 · 4 comments

Comments

@matthewp
Copy link
Contributor

Summary

A brief, one or two sentence explanation of the proposal.

Add an API to integrations which allows them to define middleware so that users do not need to go through the boilerplate of creating a middleware file and importing the functionality.

Background & Motivation

When we built the middleware API we anticipated a need for integrations to hook into it, but we decided not to make that a goal for v1 due to the complexity of ordering. Yet the need keeps coming up for the same reasons as before, integrations want to transparently add middleware.

Goals

  • The ability to get middleware into an Astro project simply by adding an integration as normal.
  • Allow an integration to place itself either at the front or end of the stack in terms of ordering.

Non-Goals

  • Not aiming for full control over middleware ordering at this stage. Middleware ordering is determined dynamically as the root middleware module is defined, so an API that allowed integration control over that would be difficult and more broad than in this proposal. There is no known use-case for this regardless.
@github-project-automation github-project-automation bot moved this to Stage 2: Accepted Proposals, No RFC in Public Roadmap Sep 19, 2023
@jlarmstrongiv
Copy link

Great! I currently generate the middleware file if it doesn’t exist. It would mean users no longer have to set up their own middleware and sequence either. Looking forward to this update 👍

@matthewp matthewp moved this from Stage 2: Accepted Proposals, No RFC to Stage 3: Accepted Proposals, Has RFC in Public Roadmap Oct 19, 2023
@matthewp matthewp moved this from Stage 3: Accepted Proposals, Has RFC to Implemented in Public Roadmap Nov 6, 2023
@florian-lefebvre
Copy link
Member

@matthewp can this issue be closed?

@matthewp
Copy link
Contributor Author

Yes it can, thanks for the reminder!

@jlarmstrongiv
Copy link

Thank you @matthewp I just updated astro-i18n-aut to use the new integration hooks—it works great 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Implemented
Development

No branches or pull requests

3 participants