Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFromHTTPConfig ¶
func NewFromHTTPConfig(path string, httpConfig map[string]any, provider pkgsync.SecretProvider) (*httpsync.HttpDataSynchronizer, error)
NewFromHTTPConfig creates a new HTTP Synchronizer using a map-based configuration. This is the recommended constructor for external projects.
The httpConfig map should contain the following fields:
- "url" (string, required): HTTP endpoint URL
- "method" (string, optional): HTTP method (default: "GET")
- "body" (string, optional): Request body (for POST/PUT)
- "headers" (map[string]any, optional): Custom HTTP headers
- "credential" (string, optional): Name of credential to use for authentication
The path parameter specifies where to save the downloaded data.
The secretProvider is required if credentials are needed. The provider will be called with the credential name to retrieve the actual credentials.
Example usage:
httpConfig := map[string]any{
"url": "https://api.example.com/data.json",
"method": "GET",
"headers": map[string]any{"Accept": "application/json"},
"credential": "api-bearer-token",
}
provider := myorg.NewWhisperSecretProvider(whisperClient)
syncer, err := httpsync.NewFromHTTPConfig("/path/to/save.json", httpConfig, provider)
if err != nil {
log.Fatal(err)
}
err = syncer.Execute(ctx)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.