Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning values from filters #31

Closed
thekid opened this issue Jan 21, 2018 · 0 comments
Closed

Returning values from filters #31

thekid opened this issue Jan 21, 2018 · 0 comments

Comments

@thekid
Copy link
Member

thekid commented Jan 21, 2018

For easier testing, if filter() returned whatever Invocation::proceed() returned (which is typically the case, most filters are implemented w/ return $invocation->proceed($request, $response);), and Invocation::proceed() returned whatever routing returns, then we could simplify the following:

// Before
private function filter(Request $request): Request {
  new BehindProxy()->filter(
    $request,
    new Response(new TestOutput()),
    new Invocation(Routing::cast(function($req, $res) use(&$passed) { $passed= $req; }))
  );
  return $passed;
}

// After
private function filter(Request $request): Request {
  return new BehindProxy()->filter(
    $request,
    new Response(new TestOutput()),
    new Invocation(Routing::cast(($req, $res) ==> $req))
  );
}

On a side note, Invocation could be more liberal in what it accepts, calling Routing::cast() internally.

thekid added a commit that referenced this issue Jan 21, 2018
@thekid thekid closed this as completed Jan 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant