Skip to content

Integration hooks for middleware #709

@matthewp

Description

@matthewp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Implemented

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions