Use bespoke HTTP messages are bespokemessages, not PSR-7
- Comparing
- v1 to v2
- Current
- Read the document
Context
PSR-7 defines common is a shared set of HTTP message interfacesinterfaces for PHP, and PSR-15 defines adds handler and middleware interfaces over them. Their
value .
What they offer is interchangeability: middleware written against them can be shared between frameworks, works in any framework that implements them,
and a message can be
passed be handed to any library that speaks the same interfaces.
The panel is a bespoke, one purpose-built system running as a single binary on one runtime, per
as
ADR-0009 decides. Nothing outside it touches handles its
messages: module module authors write actions, which and an action never see sees a request object.
The interfaces are also nearly a decade old, and a . A message built to them is shaped by takes its shape from that API rather than by from what the
panel needs.
Decision
The engine defines its I will define the engine's own request and response objects, and the its own contracts for handling handling
them. It does The panel will not implement
implement PSR-7 or PSR-15, and nothing in the panel depends it will depend on their interfaces.
Alternatives
Implementing PSR-7 and PSR-15, so that middleware written for other frameworks could be usedrun in the panel. The
I rejected
this because that interchangeability does not apply to buys nothing in a bespoke system where nothing no code outside the engine the
engine holds a message, and adopting
the interfaces it would put a dated API on every internal call site, shaping the the
design around the standard rather than
than around the panel.
No other alternative was weighed.
Consequences
Easier:
- The messages will be shaped around what the panel needs, and built
the wayas immutable value objects like the rest ofthe engine is built, with immutable value objectsthe engine. - A request will describe what arrived and nothing more, since
there isno interfacerequiringwill require an attribute bagto carryfor carrying state through a pipeline.
Harder:
- Middleware written for other frameworks
cannot be used, and anywill not run in the panel. Any that is wantedhaswill have to bewrittenwritten againstthethe engine's own contracts.
Constrained:
- Every component that handles a request or produces a response
dependswill depend on the engine'sownown message types.
Sources
- Issue #62, Engine - HTTP, , edited through to narrow its scope and to state content
directly rather than citing closed issues: the decision, which is
createdanddecided, andtheits reasons, that: PSR-77 exists so middleware can be shared between frameworks,thatnothing outside the engine touches theseclasses becauseclasses because module authors write actions, andthatit would put a 2016-era API on every internal call site fornono interoperability. - Issue #64, Engine - HTTP - Messages, : bespoke immutable messages built on property hooks and
private(set), a request with no attribute bag, and the statement that the reasoningfor itis recorded in #62. - The decision following the same reasoning as ADR-0004, that a
PSR
curbsconstrains how a design can be shaped and does not fit a bespoke system: first written down on .
Source adr/0018-bespoke-http-messages.md · commit 9444a99 · published