Skip to content

Conversation

@Joshhua5
Copy link

@Joshhua5 Joshhua5 commented Jan 8, 2025

Something like this would solve all of our needs for matching, if you approve of the direction, I'll go ahead and add the documentation and additional tests.

@sandermvanvliet
Copy link
Owner

I'm not sure I would want to take this direction with the package because it moves away from the expressiveness I had in mind when I built this.
I appreciate that this is an approach that would allow for any kind of matching but at it comes at the cost of readability.

Let me try to explain what I mean by that.

Consider someone stumbling on this library (or in existing code via IntelliSense) and seeing the AndWhen() method, they might be inclined to write something like this:

handler
    .RespondTo()
    .Get()
    .AndWhen(req => req.Path == "whatever" &&
        reg.Headers.Accept == "text/plain" &&
        req.Headers["Cookie"] == "testcookie=1");

which is (again, in my opinion) harder to understand than it's equivalent:

handler
    .RespondTo()
    .Get()
    .ForUrl("whatever")
    .Accepting("text/plain")
    .AndCookie("testcookie", "1");

While this may seem contrived I want to push people into the pit of success and guide to the intended usage.

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

Successfully merging this pull request may close these issues.

2 participants