Verbessere die URL-Bau-Logik im Client; stelle sicher, dass der Basis-Pfad nicht ersetzt wird, wenn der Dienst-Pfad absolut ist
This commit is contained in:
@@ -31,18 +31,18 @@ type Client struct {
|
|||||||
userAgent string
|
userAgent string
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
Flows *FlowsService
|
Flows *FlowsService
|
||||||
FlowRuns *FlowRunsService
|
FlowRuns *FlowRunsService
|
||||||
Deployments *DeploymentsService
|
Deployments *DeploymentsService
|
||||||
TaskRuns *TaskRunsService
|
TaskRuns *TaskRunsService
|
||||||
WorkPools *WorkPoolsService
|
WorkPools *WorkPoolsService
|
||||||
WorkQueues *WorkQueuesService
|
WorkQueues *WorkQueuesService
|
||||||
Variables *VariablesService
|
Variables *VariablesService
|
||||||
Logs *LogsService
|
Logs *LogsService
|
||||||
Admin *AdminService
|
Admin *AdminService
|
||||||
BlockTypes *BlockTypesService
|
BlockTypes *BlockTypesService
|
||||||
BlockSchemas *BlockSchemasService
|
BlockSchemas *BlockSchemasService
|
||||||
BlockDocuments *BlockDocumentsService
|
BlockDocuments *BlockDocumentsService
|
||||||
BlockCapabilities *BlockCapabilitiesService
|
BlockCapabilities *BlockCapabilitiesService
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +148,16 @@ func WithUserAgent(ua string) Option {
|
|||||||
|
|
||||||
// do executes an HTTP request with retry logic.
|
// do executes an HTTP request with retry logic.
|
||||||
func (c *Client) do(ctx context.Context, method, path string, body, result interface{}) error {
|
func (c *Client) do(ctx context.Context, method, path string, body, result interface{}) error {
|
||||||
// Build full URL
|
// Build full URL by joining the base URL path with the service path.
|
||||||
u, err := c.baseURL.Parse(path)
|
// url.URL.Parse() is not used here because it would replace the base path
|
||||||
|
// when the service path is absolute (starts with "/").
|
||||||
|
refURL, err := url.Parse(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse path: %w", err)
|
return fmt.Errorf("failed to parse path: %w", err)
|
||||||
}
|
}
|
||||||
|
u := *c.baseURL
|
||||||
|
u.Path = strings.TrimRight(c.baseURL.Path, "/") + "/" + strings.TrimLeft(refURL.Path, "/")
|
||||||
|
u.RawQuery = refURL.RawQuery
|
||||||
|
|
||||||
// Serialize request body if present
|
// Serialize request body if present
|
||||||
var reqBody io.Reader
|
var reqBody io.Reader
|
||||||
|
|||||||
Reference in New Issue
Block a user