mirror of
https://github.com/navidrome/navidrome.git
synced 2026-05-20 09:18:35 +00:00
Some checks are pending
Pipeline: Test, Lint, Build / Package/Release (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Test Go code (push) Waiting to run
Pipeline: Test, Lint, Build / Get version info (push) Waiting to run
Pipeline: Test, Lint, Build / Lint Go code (push) Waiting to run
Pipeline: Test, Lint, Build / Test JS code (push) Waiting to run
Pipeline: Test, Lint, Build / Lint i18n files (push) Waiting to run
Pipeline: Test, Lint, Build / Check Docker configuration (push) Waiting to run
Pipeline: Test, Lint, Build / Build (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-1 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Upload Linux PKG (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-2 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-3 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-4 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-5 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-6 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-7 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-8 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-9 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build-10 (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Push to GHCR (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Push to Docker Hub (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Cleanup digest artifacts (push) Blocked by required conditions
Pipeline: Test, Lint, Build / Build Windows installers (push) Blocked by required conditions
Allow plugins to opt out of automatic redirect following on a per-request basis. When set to true, the response returns the redirect status code and Location header directly instead of following to the final destination.
41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package host
|
|
|
|
import "context"
|
|
|
|
// HTTPRequest represents an outbound HTTP request from a plugin.
|
|
type HTTPRequest struct {
|
|
Method string `json:"method"`
|
|
URL string `json:"url"`
|
|
Headers map[string]string `json:"headers,omitempty"`
|
|
NoFollowRedirects bool `json:"noFollowRedirects,omitempty"`
|
|
Body []byte `json:"body,omitempty"`
|
|
TimeoutMs int32 `json:"timeoutMs,omitempty"`
|
|
}
|
|
|
|
// HTTPResponse represents the response from an outbound HTTP request.
|
|
type HTTPResponse struct {
|
|
StatusCode int32 `json:"statusCode"`
|
|
Headers map[string]string `json:"headers,omitempty"`
|
|
Body []byte `json:"body,omitempty"`
|
|
}
|
|
|
|
// HTTPService provides outbound HTTP request capabilities for plugins.
|
|
//
|
|
// This service allows plugins to make HTTP requests to external services.
|
|
// Requests are validated against the plugin's declared requiredHosts patterns
|
|
// from the http permission in the manifest. Redirects are followed but each
|
|
// redirect destination is also validated against the allowed hosts.
|
|
//
|
|
//nd:hostservice name=HTTP permission=http
|
|
type HTTPService interface {
|
|
// Send executes an HTTP request and returns the response.
|
|
//
|
|
// Parameters:
|
|
// - request: The HTTP request to execute, including method, URL, headers, body, and timeout
|
|
//
|
|
// Returns the HTTP response with status code, headers, and body.
|
|
// Network errors, timeouts, and permission failures are returned as Go errors.
|
|
// Successful HTTP calls (including 4xx/5xx status codes) return a non-nil response with nil error.
|
|
//nd:hostfunc
|
|
Send(ctx context.Context, request HTTPRequest) (*HTTPResponse, error)
|
|
}
|