Create a middleware without yaegi

Hello, my application uses many golang features not supported by yaegi, and there is no way of removing them. Is there any way to compile traefik with custom middlewares?
I have noticed that the middlewares under /pkg/middlewares/**, so I would have to clone the project and add a directory with a New method? Is there a better way of doing it without having to fork?

Hello, my application uses many golang features not supported by yaegi, and there is no way of removing them.

Hello.
Out of curiosity, what is it exactly that is not supported by yaegi? Have you opened an issue on the yaegi project? if not, and if there isn't already one on the matter, then could you please do it?

Is there any way to compile traefik with custom middlewares?
I have noticed that the middlewares under /pkg/middlewares/**, so I would have to clone the project

yes, these are the middleware already included in traefik and available without needing the plugins mechanism.

and add a directory with a New method?

That's a start, but I don't think it would be enough.

Is there a better way of doing it without having to fork?

You could always open an issue to explain why you need that middleware, but as the plugins mechanism works well now, we avoid adding new middleware in traefik itself. So you'd have to make a very compelling argument for it to be added to /pkg/middlewares .

There are many features not supported by yaegi like sync pools declarations outside a function. That's highly unreliable for a huge library like coraza.

We have been trying to connect coraza to traefik for years without success, we have removed as many dependencies as possible, we even removed ZAP because of traefik compatibility issues.

We also use build constraints to separate between architectures, compilers, and test groups, the problem is that yaegi will just evaluate everything and we cannot tell it to ignore certain dependencies like gjson.

For example, the current status of the coraza plugin is:

test: coraza.go:9:2: import "github.com/corazawaf/coraza/v3" error: /Users/jptosso/go/src/github.com/jptosso/coraza-traefik/vendor/github.com/corazawaf/coraza/v3/transaction.go:28:2: import "github.com/corazawaf/coraza/v3/bodyprocessors" error: /Users/jptosso/go/src/github.com/jptosso/coraza-traefik/vendor/github.com/corazawaf/coraza/v3/bodyprocessors/json_unmarshaler_tinygo.go:21:2: import "github.com/tidwall/gjson" error: /Users/jptosso/go/src/github.com/jptosso/coraza-traefik/vendor/github.com/tidwall/gjson/gjson.go:1790:3: undefined: loop

I wouldn't mind it if you wanted to add coraza to pkg/middlewares though.