Radar.Adr
Radar.Adr copied to clipboard
Convert Radar to PSR-15 compatible middleware
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…
- Manually specifying a custom Input or Responder via a fluent interface when setting up the route (No impact on custom classes through auto discovery)
- Applying an
accepts()
pre-filter to help with content negotiation (as noted in the docs) - The failed route response would be handled by the router middleware, which isn't part of this package
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?
This is a neat idea. I will review it locally instead of online.
For what it's worth, here's my brainstorming on the direction I think the radar stuff should go in terms of https://github.com/jakejohns/radar-new