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

Added CookieMatches for Cookie matching on requests #141

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

BBerastegui
Copy link

With CookieMatches you will be able to trigger any behaviour if you find regexp matches against some particular cookie pattern.

@elazarl
Copy link
Owner

elazarl commented Jan 19, 2016

Hi,

Thanks for the PR.

I'm not sure if matching against the cookie representation is a good idea. I'd add a way to match
against a certain cookie's key. So that we'd match a regexp against specific Cookie(key).Value.

@BBerastegui
Copy link
Author

Hi !

In my case, I was trying to find a regexp matching cookie being sent in the request and then modifying/deleting/triggering whatever behaviour we wanted.

That is why I decided to add the same functionality as:

func ReqHostMatches(regexps ...*regexp.Regexp) ReqConditionFunc

We can add also something more strict as you propose. Something like "CookieIs" as in the host-related function, but based on the cookie key and/or value:

func ReqHostIs(hosts ...string) ReqConditionFunc

@elazarl
Copy link
Owner

elazarl commented Jan 19, 2016

Didn't you know in advance which key would the cookie contain?

On Tue, Jan 19, 2016 at 10:29 AM, Borja Berastegui <[email protected]

wrote:

Hi !

In my case, I was trying to find a regexp matching cookie being sent in
the request and then modifying/deleting/triggering whatever behaviour we
wanted.

That is why I decided to add the same functionality as:

func ReqHostMatches(regexps ...*regexp.Regexp) ReqConditionFunc

We can add also something more strict as you propose. Something like
"CookieIs" as in the host-related function, but based on the cookie key
and/or value:

func ReqHostIs(hosts ...string) ReqConditionFunc


Reply to this email directly or view it on GitHub
#141 (comment).

@BBerastegui
Copy link
Author

In my specific case yes, one key in particular.

But in the case that the key might be variable (I've seen several applications doing this), it will be great to be able to match it using a regexp.

@elazarl
Copy link
Owner

elazarl commented Jan 19, 2016

In this case we should give two regexp, for the key and for the value.

This would avoid all the key escaping problems.

On Tue, Jan 19, 2016 at 10:42 AM, Borja Berastegui <[email protected]

wrote:

In my specific case yes, one key in particular.

But in the case that the key might be variable (I've seen several
applications doing this), it will be great to be able to match it using a
regexp.


Reply to this email directly or view it on GitHub
#141 (comment).

@BBerastegui
Copy link
Author

So, two separate functions like:

func CookieKeyMatches(regexps ...*regexp.Regexp) ReqConditionFunc

And:

func CookieValueMatches(regexps ...*regexp.Regexp) ReqConditionFunc

Or one function with two parameters:

func CookieMatches(regexpKey *regexp.Regexp, regexpValue *regexp.Regexp) ReqConditionFunc

Or:

func CookieMatches(regexpKey *regexp.Regexp, regexpValue *regexp.Regexp) ReqConditionFunc

?

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