 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPProcessor ¶ added in v0.13.4
type HTTPProcessor struct {
	sdk.UnimplementedProcessor
	// contains filtered or unexported fields
}
    Example ¶
p := NewHTTPProcessor(conduit_log.Nop())
srv := newTestServer()
// Stop the server on return from the function.
defer srv.Close()
exampleutil.RunExample(p, exampleutil.Example{
	Summary: `Send a request to an HTTP server`,
	Description: `
This example shows how to use the HTTP processor to send a record's ` + "`.Payload.After`" + ` field as a string to a dummy
HTTP server that replies back with a greeting.
The record's ` + "`.Payload.After`" + ` is overwritten with the response. Additionally, the example shows how to set a request
header and how to store the value of the HTTP response's code in the metadata field ` + "`http_status`" + `.`,
	Config: config.Config{
		"request.url":          srv.URL,
		"request.body":         `{{ printf "%s" .Payload.After }}`,
		"response.status":      `.Metadata["http_status"]`,
		"headers.content-type": "application/json",
	},
	Have: opencdc.Record{
		Operation: opencdc.OperationUpdate,
		Position:  opencdc.Position("pos-1"),
		Payload: opencdc.Change{
			After: opencdc.RawData("world"),
		},
	},
	Want: sdk.SingleRecord{
		Operation: opencdc.OperationUpdate,
		Position:  opencdc.Position("pos-1"),
		Metadata: map[string]string{
			"http_status": "200",
		},
		Payload: opencdc.Change{
			After: opencdc.RawData("hello, world"),
		},
	},
})
Output: processor transformed record: --- before +++ after @@ -1,10 +1,12 @@ { "position": "cG9zLTE=", "operation": "update", - "metadata": null, + "metadata": { + "http_status": "200" + }, "key": null, "payload": { "before": null, - "after": "world" + "after": "hello, world" } }
Example (DynamicURL) ¶
p := NewHTTPProcessor(conduit_log.Nop())
srv := newTestServer()
// Stop the server on return from the function.
defer srv.Close()
exampleutil.RunExample(p, exampleutil.Example{
	Summary: `Send a request to an HTTP server with a dynamic URL`,
	Description: `
This example shows how to use the HTTP processor to use a record's ` + "`.Payload.After.name`" + ` field in the URL path,
send it to a dummy HTTP server, and get a greeting with the name back.
The response will be written under the record's ` + "`.Payload.After.response`.",
	Config: config.Config{
		"request.url":   srv.URL + "/{{.Payload.After.name}}",
		"response.body": ".Payload.After.response",
	},
	Have: opencdc.Record{
		Operation: opencdc.OperationCreate,
		Position:  opencdc.Position("pos-1"),
		Payload: opencdc.Change{
			After: opencdc.StructuredData{
				"name": "foo",
			},
		},
	},
	Want: sdk.SingleRecord{
		Operation: opencdc.OperationCreate,
		Position:  opencdc.Position("pos-1"),
		Payload: opencdc.Change{
			After: opencdc.StructuredData{
				"name":     "foo",
				"response": []byte("hello, foo!"),
			},
		},
	},
})
Output: processor transformed record: --- before +++ after @@ -1,12 +1,13 @@ { "position": "cG9zLTE=", "operation": "create", "metadata": null, "key": null, "payload": { "before": null, "after": { - "name": "foo" + "name": "foo", + "response": "aGVsbG8sIGZvbyE=" } } }
func NewHTTPProcessor ¶
func NewHTTPProcessor(l log.CtxLogger) *HTTPProcessor
func (*HTTPProcessor) Process ¶ added in v0.13.4
func (p *HTTPProcessor) Process(ctx context.Context, records []opencdc.Record) []sdk.ProcessedRecord
func (*HTTPProcessor) Specification ¶ added in v0.13.4
func (p *HTTPProcessor) Specification() (sdk.Specification, error)
 Click to show internal directories. 
   Click to hide internal directories.