api-design

  • A CDN in front of an API needs a Vary header

    A cache keys on the URL. If the response depends on anything else — an Accept header, a language, an authorisation token — the cache will serve one…

  • Route model binding with a custom key per route

    getRouteKeyName() changes the binding column for a model everywhere, which is wrong when the admin addresses an order by id and the customer addresses it by reference. An…

  • A contract test for the API you depend on

    Mocking an upstream service makes the suite fast and guarantees nothing about the upstream still behaving that way. A contract test is a small suite that runs against…

  • HTTP caching headers the application controls

    A reverse proxy or CDN caches what the response tells it to cache, which means the decision belongs in the application and usually is not made at all…

  • Events describe what happened, commands ask for something

    Both end up on the same bus and they are opposites. A command is addressed to one handler and may be refused; an event is a statement of…

  • API resources replaced the transformer package

    Shaping a model for JSON has meant a transformer library or toArray() on the model, and the second couples the wire format to the database columns — so…

  • The REST API in core, and the plugin it replaces

    4.7 shipped the content endpoints. What moving off the feature plugin involves, why authentication is still the unsolved half, and the read API every site now exposes.

  • Extracting a service without a rewrite

    The reporting code had one caller and a six-hour test run. Finding the seam, dealing with the shared schema honestly, and routing traffic gradually rather than switching.

  • Idempotency keys are what make a retry safe

    A client that times out cannot tell whether the request was processed. Retrying risks a double charge; not retrying risks losing the order. The only way out is…

  • fetch does not reject on a 404

    fetch rejects on a network failure and resolves on every HTTP response, including 404 and 500. Code that only has a catch therefore treats an error page as…