that cipher
has also StreamReader
\tdecompress, _ := gzip.NewReader(httpBody)\n\treader := cipher.StreamReader{S: stream, R: decompress}
maybe this can be combined with something similar to gzip middleware?
\nnb: I have not tried this myself.
","upvoteCount":0,"url":"https://github.com/labstack/echo/discussions/2706#discussioncomment-11332386"}}}-
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.
-
@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