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

Additional implementations of RequestMatcher #117

Open
localheinz opened this issue Aug 3, 2019 · 1 comment
Open

Additional implementations of RequestMatcher #117

localheinz opened this issue Aug 3, 2019 · 1 comment

Comments

@localheinz
Copy link
Contributor

Q A
Bug? no
New Feature? yes
Version n/a

Question

In a project we are currently using implementations of the RequestMatcher which allow us to reuse and compose request matchers.

For example

$httpClient->on(
    AllOf::matchers(
        Method::is('GET'),
        Path::is('foo/bar'),
        Uri\QueryParameters::are([
            'baz' => '1',
            'qux' => 'hmm',
        ])
    ),
    new Psr7\Response(Http::OK)
);

Would there be interest in having these pushed upstream, that is, into this repository?

@dbu
Copy link
Contributor

dbu commented Aug 6, 2019

i think generally we are open to contributions.

while this is quite expressive to read, i think this creates a lot of classes and method calls. how about a RequestMatcherFactory with fluent interface?

$rmf
    ->method('GET')
    ->path('foo/bar')
    ->queryParameters(['baz' => '1'])
    ->getMatcher()
;

i see that your approach could also do AnyOf or something like that, but i doubt that comes up much - and there is still the CallbackRequestMatcher for such situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants