noodlehaus/dispatch

Look into allowing arguments to be passed to `next(...)` from within the middleware

Closed this issue · 1 comments

Right now, middleware functions have no way of forwarding values down the chain, except via stash(...). It might be good to allow value passing via the next(...) call.

function jwt_verify(callable $next) {
  # ...
  $data = jwt_decode(...);
  return $next($data);
}

This passed parameter then gets appended to the list of args that gets passed down the chain. Succeeding middleware and handlers can then access this additional parameter from the tailing ...$args.

Right now, it seems like stash(...) is still the best approach as it's more predictable.

Reference: #105 (comment)