-
For example, I got a service that receives request from client, and decrypts its body, process the plain data, and then returns a encrypted response. I would like to use middlewares to implement this function. For now, I can write a decrypt middleware just like normal middleware that works at "OnRequest-like" stage, but I don't know how to write a encrypt middleware that works at "OnResponse-like The full path I want is like this: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@JobberRT do you want to build browser based encryption of body? If not then maybe it would be easier to encrypt whole connection and use |
Beta Was this translation helpful? Give feedback.
if it is only body then probably you can take https://github.com/labstack/echo/blob/master/middleware/body_dump.go middleware and create writer than encrypts responses and replace request body reader with something that decrypts into memory and replaces body.
reading https://groups.google.com/g/golang-nuts/c/fIOM5sZto0I point to this example that has streamWriter https://go.dev/play/p/4CX1J_IYqk