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.
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 👍
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
Non-Goals