Revanth14 commented on code in PR #1324:
URL: https://github.com/apache/iceberg-go/pull/1324#discussion_r3496610785


##########
catalog/rest/rest.go:
##########
@@ -287,7 +295,48 @@ func (s *sessionTransport) RoundTrip(r *http.Request) 
(*http.Response, error) {
        return s.RoundTripper.RoundTrip(r)
 }
 
-func do[T any](ctx context.Context, method string, baseURI *url.URL, path 
[]string, cl *http.Client, override map[int]error, allowNoContent bool) (ret T, 
err error) {
+// reqConfig holds the optional per-request knobs shared by do and doPost:
+// headers to set, session-default headers to suppress, and whether an HTTP 204
+// is a valid empty result.
+type reqConfig struct {
+       headers         map[string]string
+       suppressHeaders []string
+       allowNoContent  bool
+}
+
+type reqOption func(*reqConfig)
+
+// withHeaders sets per-request headers. They take precedence over session
+// defaults because sessionTransport.RoundTrip skips any default whose key is
+// already present on the request.
+func withHeaders(headers map[string]string) reqOption {
+       return func(c *reqConfig) { c.headers = headers }
+}
+
+// withSuppressedHeaders prevents the named session-default headers from being
+// sent on this request. See suppressRequestHeaders for the mechanism.
+func withSuppressedHeaders(names ...string) reqOption {

Review Comment:
   Addressed.
   
   `withHeaders` now merges into the existing header map instead of replacing 
it, and `withSuppressedHeaders` appends to the existing suppression list 
instead of replacing it. I also added a direct `TestReqOptionsCompose` test 
that exercises multiple `withHeaders` and multiple `withSuppressedHeaders` 
options on the same request config.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to