syndesisio / connectors

Apache Camel Connectors for Syndesis
Apache License 2.0
6 stars 12 forks source link

feat: Swagger Connector #99

Closed zregvart closed 6 years ago

zregvart commented 6 years ago

Adds a Initial implementation of a Connector that uses Swagger specification to invoke REST services.

Fixes #96

davsclaus commented 6 years ago

Ah yeah I can see the problem. You need to determine the headers in the createEndpoint method. And then you have trouble to set those headers before calling the producer.

We have some support for this by using a Processor and set that as setBeforeProducer in the component class. Then this processor will be invoked before the producer. However this processor is shared, and therefore you cannot store local state such as the headers.

So we should make it possible to set a instance of BeforeProducer on the endpoint, so you can do it all from the createEndpoint class.

Then you just set

 Map headers = ... determineHeaders
 endpoint.setBeforeProducer(e -> e.getIn().setHeaders(headers));
davsclaus commented 6 years ago

I logged a ticket: https://issues.apache.org/jira/browse/CAMEL-11975

And there is a commit https://github.com/apache/camel/commit/ceb8669704f87561c53a4324893b5fb31302e704

Now you can do what I do in that FooComponent in the createEndpoint method of your connector. You should just use setBeforeProducer instead.

zregvart commented 6 years ago

Moved to https://github.com/syndesisio/syndesis/pull/397