How to access request and response in the plugin

We want to use the gateway for measuring the response bytes for each request. But I cannot access the response and request in same plugin.
Can you please provide reference to a documentation or github example where we can do this.

Hi @amanjain5221,

Welcome to the community! :tada:

A Golang response plugin should do it.

package main

import (
	"net/http"

	"github.com/TykTechnologies/tyk/log"
)

var logger = log.Get()

func GetLengths(rw http.ResponseWriter, res *http.Response, req *http.Request) {

	request_length := req.ContentLength
	logger.Info("Request content length:  ", request_length)

	response_length := res.ContentLength
	logger.Info("Response content length:  ", response_length)

}

func main() {}

I’ve moved your post to the support section as its better suited for your question. :slightly_smiling_face: