Convert Radar to PSR-15 compatible middleware #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This isn't meant to be merged in. Given the magnitude of changes made here, I just wanted to get initial reactions. Is this a direction the maintainers want to take this project?
No documentation or tests yet. Just the minimum necessary for a working proof-of-concept.
This is intended to become a new repository/package called Radar.Middleware. I'm working on another fork to modify the existing Radar.Adr to become just a micro-framework that wires up Aura.Di, Aura.Router, Relay 2.x, and the new Radar.Middleware, but there's no need to do that if this proposal isn't accepted.
Radar.Middleware is a fully PSR-15 compatible middleware package, uncoupled to any particular DI, middleware dispatcher, or router. It works with any PSR-11 compatible DI and any PSR-15 compatible dispatcher. And it can be used in combination with any PSR-15 compatible router that passes the route handler to the next middleware through a request attribute (customizable but named
request-handler
by default) such as these. It effectively subs in as an ADR-specific alternative to middlewares/request-handler. (See how that middleware is used.)This change does remove some features though. Since Radar.Middleware is no longer coupled to Aura.Router, it can't provide route- and responder-specific features like…
accepts()
pre-filter to help with content negotiation (as noted in the docs)My motivation here is to give us an ADR handler that can be used in a much wider variety of projects than just greenfield projects that start with Radar.Project. I've personally got a side project where I'm using PHP-DI, FastRoute, and Relay 2.x, so the existing Radar skeleton won't work. And I can see use cases for modernizing legacy projects that eventually want to move to an ADR pattern. Interoperability FTW!
So, thoughts?