@@ -12,6 +12,13 @@ import (
1212 "go.uber.org/zap"
1313)
1414
15+ // methodsWithBody is a set of HTTP methods that benefit from logging the request body.
16+ var methodsWithBody = map [string ]bool {
17+ "POST" : true ,
18+ "PUT" : true ,
19+ "PATCH" : true ,
20+ }
21+
1522// MarshalRequest encodes the request body as JSON for the Microsoft Graph API.
1623// This function takes an interface{} type body, an HTTP method, and an endpoint as input,
1724// and returns the marshaled JSON byte slice along with any error encountered during marshaling.
@@ -30,6 +37,8 @@ import (
3037// Logging:
3138// - Logs an error if JSON marshaling fails.
3239// - Logs the JSON request body for POST, PUT, and PATCH methods.
40+ //
41+ // Set of methods that require logging the request body
3342func (m * Integration ) marshalRequest (body interface {}, method string , endpoint string ) ([]byte , error ) {
3443 var (
3544 data []byte
@@ -43,8 +52,8 @@ func (m *Integration) marshalRequest(body interface{}, method string, endpoint s
4352 return nil , err
4453 }
4554
46- // Log the JSON request body for POST, PUT, or PATCH methods
47- if method == "POST" || method == "PUT" || method == "PATCH" {
55+ // Log the JSON request body for methods that require it
56+ if methodsWithBody [ method ] {
4857 m .Logger .Debug ("JSON Request Body" , zap .String ("Body" , string (data )), zap .String ("Endpoint" , endpoint ))
4958 } else {
5059 m .Logger .Debug ("Request Endpoint" , zap .String ("Endpoint" , endpoint ))
0 commit comments