Rules negative lookahead

Hello I was trying to write the rule below in Traefik:

Host(`localhost`) && HeadersRegexp(`Content-Type`, `application/grpc(?!-web)(.*)`)

Unfortunately I have discovered that golang does not have negative lookahead in regular expression.
How can I write it in a way that the golang regex engine will understand.

Thank you.

Hello @itachisasuke, Is a good way to know learn and test go regexps.

Hope it helps :slight_smile:

Use the rule logical operators to advantage:

Host(`localhost`) && HeadersRegexp(`Content-Type`,`application/grpc.*`) && !HeadersRegexp(`Content-Type`,`application/grpc-web`)


Hello @tommoulard ,

I have done that unfortunately.The answer I get After googling is not supported in golang

Hello @cakiwi,

This is very simple and great.
Am not sure why I did not think of the second part.

Thank you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.