The Game Panel Design record
The Game Panel
ADR-0018 Accepted

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 way as immutable value objects like the rest of the engine is built, with immutable value objectsthe engine.
  • A request will describe what arrived and nothing more, since there is no interface requiring will require an attribute bag to carry for carrying state through a pipeline.

Harder:

  • Middleware written for other frameworks cannot be used, and any will not run in the panel. Any that is wanted has will have to be written written against the the engine's own contracts.

Constrained:

  • Every component that handles a request or produces a response depends will depend on the engine's own own 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 created and decided, and the its reasons, that : PSR-7 7 exists so middleware can be shared between frameworks, that nothing outside the engine touches these classes because classes because module authors write actions, and that it would put a 2016-era API on every internal call site for no no 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 reasoning for it is recorded in #62.
  • The decision following the same reasoning as ADR-0004, that a PSR curbs constrains 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