Ocramius / ocramius.github.com

:books: Coding thoughts and ideas by Ocramius
https://ocramius.github.io/
40 stars 26 forks source link

Blogpost: multiple chained middlewares to avoid duplicating responsibilities #105

Open Ocramius opened 7 years ago

Ocramius commented 7 years ago

See following example of a CQRS-style routing. The read side is re-used as a fallback of the write side. Still under discussion: shared mutable state in the form component.

988c25
Ocramius commented 7 years ago

As discussed with @weierophinney, it's better to return $next($req, $res)->withStatusCode(400); rather than passing down a modified request.