Skip to content

Refactor HTTP calls to use host.HTTPSend#12

Open
Copilot wants to merge 5 commits intomainfrom
copilot/refactor-http-api-usage
Open

Refactor HTTP calls to use host.HTTPSend#12
Copilot wants to merge 5 commits intomainfrom
copilot/refactor-http-api-usage

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

Migrates outbound HTTP from the deprecated pdk.NewHTTPRequest().Send() pattern to host.HTTPSend, as recommended by Navidrome upstream following the addition of the HTTP host service in the PDK.

Changes

  • go.mod: Bumped PDK to v0.0.0-20260224192836-652c27690be6 (first version shipping host.HTTPSend)
  • main.go / audiomuse_api.go: Replaced all pdk.NewHTTPRequest usages with host.HTTPSend; status checks now use resp.StatusCode (int32) and body access uses resp.Body ([]byte field); network/transport errors are now surfaced as Go errors rather than swallowed into a non-200 status check
  • .gitignore: Added compiled binary to ignore list

Before / After

// Before
req := pdk.NewHTTPRequest(pdk.MethodGet, apiURL)
resp := req.Send()
if resp.Status() != 200 { ... }
body := resp.Body()

// After
resp, err := host.HTTPSend(host.HTTPRequest{Method: "GET", URL: apiURL})
if err != nil { return nil, fmt.Errorf("AudioMuse-AI HTTP request failed: %w", err) }
if resp.StatusCode != 200 { ... }
body := resp.Body
Original prompt

Refactor the plugin to use the new Navidrome plugin host HTTP API. Replace all usages of pdk.NewHTTPRequest and .Send() with direct calls to host.HTTPSend everywhere outbound HTTP is performed. Ensure:

  • Import the host package from github.com/navidrome/navidrome/plugins/pdk/go/host or the latest equivalent.
  • All HTTP calls construct a host.HTTPRequest struct with Method, URL, Headers (if needed), and TimeoutMs.
  • Use host.HTTPSend to send the request and handle errors as per the new API.
  • Update error handling to use Go’s error return pattern and check resp.StatusCode.
  • Remove any unused pdk HTTP wrapper code.
  • Refactor across main.go, audiomuse_api.go, or anywhere else HTTP calls are made.
  • Add a comment explaining the migration for future maintainers.
  • Existing functionality should remain unchanged, but HTTP handling is now done via host.HTTPSend as recommended by Navidrome upstream.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 24, 2026 23:40
Co-authored-by: NeptuneHub <171392533+NeptuneHub@users.noreply.github.com>
Co-authored-by: NeptuneHub <171392533+NeptuneHub@users.noreply.github.com>
Co-authored-by: NeptuneHub <171392533+NeptuneHub@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor plugin to use Navidrome plugin host HTTP API Refactor HTTP calls to use host.HTTPSend Feb 24, 2026
@NeptuneHub NeptuneHub marked this pull request as ready for review March 1, 2026 16:44
@NeptuneHub
Copy link
Owner

This PR will work with navidrome 0.60.4 or with the actual develop image Version: 0.60.3-SNAPSHOT (4e34d3ac).

It implement a more stable way to handle the http call that is NOT supported on previous version of navidrome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants