Skip to content

Commit 72f820b

Browse files
committed
Refactor getContentTypeHeader function to handle packages endpoint and improve logging
1 parent c9bda7a commit 72f820b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

jamf/jamfprointegration/headers.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ import (
1515
// If the endpoint does not match any of the predefined patterns, "application/json" is used as a fallback.
1616
// This method logs the decision process at various stages for debugging purposes.
1717
func (j *Integration) getContentTypeHeader(endpoint string) string {
18+
if strings.Contains(endpoint, "/api/v1/packages") {
19+
j.Logger.Debug("Content-Type for packages endpoint set to application/octet-stream", zap.String("endpoint", endpoint))
20+
return "application/octet-stream"
21+
}
22+
1823
if strings.Contains(endpoint, "/JSSResource") {
1924
j.Logger.Debug("Content-Type for endpoint defaulting to XML for Classic API", zap.String("endpoint", endpoint))
2025
return "application/xml"
21-
} else if strings.Contains(endpoint, "/api") {
26+
}
27+
28+
if strings.Contains(endpoint, "/api") {
2229
j.Logger.Debug("Content-Type for endpoint defaulting to JSON for JamfPro API", zap.String("endpoint", endpoint))
2330
return "application/json"
2431
}

0 commit comments

Comments
 (0)