You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: fix removed opensearch.BuildRequest reference in v4 upgrade guide (#978)
* docs: fix removed opensearch.BuildRequest reference in v4 upgrade guide
The 4.7.0 migration section and the raw-JSON usage guide told readers to
forward a custom Request.GetRequest to opensearch.BuildRequest, but that helper
was removed in 4.7.0 -- the very release the section documents. Replace it with
a net/http-based before/after example (relative path; the transport prepends
the base URL).
Backport of the v4-applicable portion of the #977 fix from main.
Reported in #977.
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
This change is invisible to almost all callers: the typed `Req` structs that the client consumes (e.g. `opensearchapi.SearchReq`, the v5-preview `opensearchapi.IndexReq`) already implement the new signature. Only code that defines a custom type satisfying `opensearch.Request` is affected. If you maintain such a type, add a `method string` parameter and forward it to your underlying `http.NewRequest` call (or `opensearch.BuildRequest`).
171
+
This change is invisible to almost all callers: the typed `Req` structs that the client consumes (e.g. `opensearchapi.SearchReq`, the v5-preview `opensearchapi.IndexReq`) already implement the new signature. Only code that defines a custom type satisfying `opensearch.Request` is affected.
172
+
173
+
If you maintain such a type, add a `method string` parameter and forward it to your request builder. The `opensearch.BuildRequest` helper that earlier v4 releases exposed for this purpose was **removed in 4.7.0**; construct the request with `net/http` directly instead. Give the path a leading slash (e.g. `/_plugins/my_plugin/status`) -- the transport prepends the base URL by string concatenation, so a path without a leading slash produces a malformed URL.
174
+
175
+
```go
176
+
// Before (<= 4.6.0): method stored on the struct, built via the removed
177
+
// opensearch.BuildRequest helper (which set Content-Type for a non-nil body).
`opensearch.BuildRequest` also accepted `params map[string]string` and `headers http.Header` arguments. To preserve those, set them on the `*http.Request` after construction: encode params onto `req.URL.RawQuery` (via `url.Values`) and add headers to `req.Header`.
0 commit comments