File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
internal/server/middleware Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 22package middleware
33
44import (
5- "io "
5+ "bytes "
66 "net/http"
77
88 "github.com/srg-bnd/observator/internal/server/logger"
@@ -27,15 +27,16 @@ func NewChecksum(checksumService ChecksumBehaviour) *Checksum {
2727
2828func (c * Checksum ) WithVerify (next http.Handler ) http.Handler {
2929 return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
30- body , err := io .ReadAll (r .Body )
31-
32- if err != nil {
33- http .Error (w , err .Error (), http .StatusInternalServerError )
34- logger .Log .Info (ErrReadBody , zap .Error (err ))
35- return
36- }
37-
38- defer r .Body .Close ()
30+ // body, err := io.ReadAll(r.Body)
31+ // if err != nil {
32+ // http.Error(w, err.Error(), http.StatusInternalServerError)
33+ // logger.Log.Info(ErrReadBody, zap.Error(err))
34+ // return
35+ // }
36+
37+ buf := new (bytes.Buffer )
38+ buf .ReadFrom (r .Body )
39+ body := buf .Bytes ()
3940
4041 if r .Header .Get ("HashSHA256" ) != "" && len (body ) > 0 {
4142 if err := c .ChecksumService .Verify (r .Header .Get ("HashSHA256" ), string (body )); err != nil {
You can’t perform that action at this time.
0 commit comments