Skip to content

Plugin middleware registration #1981

@bpamiri

Description

@bpamiri

Summary

Plugins cannot register middleware with the middleware pipeline (#1906). A plugin that needs request-level behavior (auth checks, CORS, rate limiting) must inject into controller scopes via mixins — the wrong abstraction level.

Proposed API

Via onPluginLoad

function onPluginLoad(app) {
    app.addMiddleware("plugins.myPlugin.MyMiddleware");
}

Via plugin.json

{
  "middleware": ["AuthMiddleware", "CorsMiddleware"]
}

Behavior

  • During plugin loading, middleware declarations are collected
  • After all plugins load, declared middleware is appended to the middleware pipeline
  • Order follows plugin load order (which follows alphabetical or explicit ordering)
  • The middleware pipeline (Middleware pipeline #1906) already supports dynamic registration — this just adds the plugin integration point

Files

  • vendor/wheels/Plugins.cfc — collect middleware declarations during load
  • vendor/wheels/events/onapplicationstart.cfc — register collected middleware with pipeline

Phase

Phase 2 — DI Integration & Lifecycle (3.x, backward compatible)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions