radarphp / Radar.Adr

The Action-Domain-Responder core for Radar.
MIT License
55 stars 7 forks source link

PSR15 lamba style middleware branch? #31

Closed jakejohns closed 7 years ago

jakejohns commented 8 years ago

Do we need/want a PSR15 (ie. Telegraph branch/fork/whatever)? Is PSR15 going to be the future?

One thing I wasn't sure about (and also pertains to arbiterphp/Arbiter.Arbiter#5 ) was if the Responder should have a dependency on the Response or if the handler should be something more like:


public function __invoke($request, $next)
{
    $action   = $request->getAttribute('radar/adr:action');
    $request  = $request->withoutAttribute('radar/adr:action');
    $response = $next($request); // before? after?
    return $this->handle($action, $request, $response);
}

This would assume some "Final Response Factory Middleware"i that would probably be part of Telegraph\Middleware, ie: ( telegraphp/telegraph.middleware#2 )

public function __invoke($request, $next)
{
    return new Response;
}

This would also mean the handler for Arbiter would not be like what currently is present in the above mentioned fork/pr.

pmjones commented 7 years ago

Hi @jakejohns ,

Again, sorry to take so long to respond on these. The relevant PSRs are kind of up-in-the-air right now, so it's hard to target against them.

Having said that: yes, if/when PSR-15 and 17 come to fruition, then Radar and Relay (etc) will probably need updates. Telegraph is the starting point for that, but the idea would be to roll Telegraph back into Relay for a second version of Relay, then update Radar accordingly.

I hope that makes sense, and thanks for your patience with all of this.

jakejohns commented 6 years ago

@pmjones I think PSR15 is accepted now: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-15-request-handlers.md