File tree Expand file tree Collapse file tree 4 files changed +32
-7
lines changed
internals/proxy/middlewares Expand file tree Collapse file tree 4 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,14 @@ func mappingHandler(next http.Handler) http.Handler {
6161 if modifiedBody {
6262 body .Data = bodyData
6363
64- log .Debug ("Applied Data Aliasing: " , body .Data )
64+ err := body .Write (req )
65+
66+ if err != nil {
67+ http .Error (w , "Internal Error" , http .StatusInternalServerError )
68+ return
69+ }
6570
66- body . Write ( req )
71+ log . Debug ( "Applied Data Aliasing: " , body . Data )
6772 }
6873
6974 next .ServeHTTP (w , req )
Original file line number Diff line number Diff line change @@ -60,9 +60,14 @@ func messageHandler(next http.Handler) http.Handler {
6060 if modifiedBody {
6161 body .Data = bodyData
6262
63- log .Debug ("Applied Message Templating: " , body .Data )
63+ err := body .Write (req )
64+
65+ if err != nil {
66+ http .Error (w , "Internal Error" , http .StatusInternalServerError )
67+ return
68+ }
6469
65- body . Write ( req )
70+ log . Debug ( "Applied Message Templating: " , body . Data )
6671 }
6772
6873 next .ServeHTTP (w , req )
Original file line number Diff line number Diff line change @@ -72,9 +72,14 @@ func templateHandler(next http.Handler) http.Handler {
7272 if modifiedBody {
7373 body .Data = bodyData
7474
75- log . Debug ( "Applied Body Templating: " , body .Data )
75+ err := body .Write ( req )
7676
77- body .Write (req )
77+ if err != nil {
78+ http .Error (w , "Internal Error" , http .StatusInternalServerError )
79+ return
80+ }
81+
82+ log .Debug ("Applied Body Templating: " , body .Data )
7883 }
7984
8085 if req .URL .Path != "" {
Original file line number Diff line number Diff line change @@ -30,7 +30,15 @@ func (body Body) ToString() string {
3030 return string (body .Raw )
3131}
3232
33- func (body Body ) Write (req * http.Request ) {
33+ func (body * Body ) Write (req * http.Request ) error {
34+ newBody , err := CreateBody (body .Data )
35+
36+ if err != nil {
37+ return err
38+ }
39+
40+ body = & newBody
41+
3442 bodyLength := len (body .Raw )
3543
3644 if req .ContentLength != int64 (bodyLength ) {
@@ -39,6 +47,8 @@ func (body Body) Write(req *http.Request) {
3947 }
4048
4149 req .Body = io .NopCloser (bytes .NewReader (body .Raw ))
50+
51+ return nil
4252}
4353
4454func CreateBody (data map [string ]any ) (Body , error ) {
You can’t perform that action at this time.
0 commit comments