Manipulate/store request and response (e.g. as a middleware)

I'm nearly new to traefik and I've been using v2.0 for a while.
We are using this gateway to sit in front of the rest of our services and manage them.
But in the mean time, we required the need to capture 'the requests coming from user' and 'the response coming from services' and, in our case, write them to kafka, for using the data in the future.
But as we stepped through traefik middlewares (that was our first shot, expecting an existing middleware or a custom one) and seeing that we don't have this feature/middleware already, we tried to write our own middleware to do this for us. But as I went on, I understood, if I'm not mistaken, that in middlewares, we only have access to the incoming requests, but no responses!

So here's the main question:
Is it possible to capture requests and response in traefik v2.0? what about already-existing middlewares?
If not, then is it possible to access the final service response (or initial request and final response in the same place/function) in the middleware part?
If not, do you have a plan for this, i.e. manipulating/storing request/response, or should we try to implement this for ourselves?
And what are the chances that if we do it correctly, you would be welcome to accept it as a PR to main repo?

P.S: I've been looking at Headers middlware implementation and it had a similar concept, but only to add new headers to requests and responses. What we want is a middleware (or sth) to extract request and response as data logs to use later. Traefik is literally a gateway and storing data logs is a necessity, however it can be.

P.S2: I've looked into the issues about 'custom middlewares' and the solution there, mostly about another web service or golang new plugin feature or lua, weren't the one that we needed. We wanted this inside traefik.

Thanks a lot.

1 Like