Skip to content

Commit 0dc6f40

Browse files
authored
Propagate underlying context to GET/PUT requests in the autopatch handler (#1019)
1 parent ce91c48 commit 0dc6f40

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

autopatch/autopatch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func PatchResource(api huma.API, path *huma.PathItem) {
264264
resourcePath := findRelativeResourcePath(ctx.URL().Path, put.Path)
265265

266266
// Perform the get!
267-
origReq, err := http.NewRequest(http.MethodGet, resourcePath, nil)
267+
origReq, err := http.NewRequestWithContext(ctx.Context(), http.MethodGet, resourcePath, nil)
268268
if err != nil {
269269
huma.WriteErr(api, ctx, http.StatusInternalServerError, "Unable to get resource", err)
270270
return
@@ -390,7 +390,7 @@ func PatchResource(api huma.API, path *huma.PathItem) {
390390
}
391391

392392
// Write the updated data back to the server!
393-
putReq, err := http.NewRequest(http.MethodPut, resourcePath, bytes.NewReader(patched))
393+
putReq, err := http.NewRequestWithContext(ctx.Context(), http.MethodPut, resourcePath, bytes.NewReader(patched))
394394
if err != nil {
395395
huma.WriteErr(api, ctx, http.StatusInternalServerError, "Unable to put modified resource", err)
396396
return

0 commit comments

Comments
 (0)