Search in sources :

Example 1 with HttpRestHeaderFilterStrategy

use of org.apache.camel.http.common.HttpRestHeaderFilterStrategy in project camel by apache.

the class HttpComponent method createProducer.

@Override
public Producer createProducer(CamelContext camelContext, String host, String verb, String basePath, String uriTemplate, String queryParameters, String consumes, String produces, Map<String, Object> parameters) throws Exception {
    // avoid leading slash
    basePath = FileUtil.stripLeadingSeparator(basePath);
    uriTemplate = FileUtil.stripLeadingSeparator(uriTemplate);
    // get the endpoint
    String url = host;
    if (!ObjectHelper.isEmpty(basePath)) {
        url += "/" + basePath;
    }
    if (!ObjectHelper.isEmpty(uriTemplate)) {
        url += "/" + uriTemplate;
    }
    HttpEndpoint endpoint = camelContext.getEndpoint(url, HttpEndpoint.class);
    if (parameters != null && !parameters.isEmpty()) {
        setProperties(camelContext, endpoint, parameters);
    }
    String path = uriTemplate != null ? uriTemplate : basePath;
    endpoint.setHeaderFilterStrategy(new HttpRestHeaderFilterStrategy(path, queryParameters));
    // the endpoint must be started before creating the producer
    ServiceHelper.startService(endpoint);
    return endpoint.createProducer();
}
Also used : HttpRestHeaderFilterStrategy(org.apache.camel.http.common.HttpRestHeaderFilterStrategy)

Example 2 with HttpRestHeaderFilterStrategy

use of org.apache.camel.http.common.HttpRestHeaderFilterStrategy in project camel by apache.

the class HttpComponent method createProducer.

@Override
public Producer createProducer(CamelContext camelContext, String host, String verb, String basePath, String uriTemplate, String queryParameters, String consumes, String produces, Map<String, Object> parameters) throws Exception {
    // avoid leading slash
    basePath = FileUtil.stripLeadingSeparator(basePath);
    uriTemplate = FileUtil.stripLeadingSeparator(uriTemplate);
    // replace http with http4 in the host part
    host = host.replace("http", "http4");
    // get the endpoint
    String url = host;
    if (!ObjectHelper.isEmpty(basePath)) {
        url += "/" + basePath;
    }
    if (!ObjectHelper.isEmpty(uriTemplate)) {
        url += "/" + uriTemplate;
    }
    HttpEndpoint endpoint = camelContext.getEndpoint(url, HttpEndpoint.class);
    if (parameters != null && !parameters.isEmpty()) {
        setProperties(camelContext, endpoint, parameters);
    }
    String path = uriTemplate != null ? uriTemplate : basePath;
    endpoint.setHeaderFilterStrategy(new HttpRestHeaderFilterStrategy(path, queryParameters));
    // the endpoint must be started before creating the producer
    ServiceHelper.startService(endpoint);
    return endpoint.createProducer();
}
Also used : HttpRestHeaderFilterStrategy(org.apache.camel.http.common.HttpRestHeaderFilterStrategy)

Example 3 with HttpRestHeaderFilterStrategy

use of org.apache.camel.http.common.HttpRestHeaderFilterStrategy in project camel by apache.

the class JettyHttpComponent method createProducer.

@Override
public Producer createProducer(CamelContext camelContext, String host, String verb, String basePath, String uriTemplate, String queryParameters, String consumes, String produces, Map<String, Object> parameters) throws Exception {
    // avoid leading slash
    basePath = FileUtil.stripLeadingSeparator(basePath);
    uriTemplate = FileUtil.stripLeadingSeparator(uriTemplate);
    // get the endpoint
    String url = "jetty:" + host;
    if (!ObjectHelper.isEmpty(basePath)) {
        url += "/" + basePath;
    }
    if (!ObjectHelper.isEmpty(uriTemplate)) {
        url += "/" + uriTemplate;
    }
    JettyHttpEndpoint endpoint = camelContext.getEndpoint(url, JettyHttpEndpoint.class);
    if (parameters != null && !parameters.isEmpty()) {
        setProperties(camelContext, endpoint, parameters);
    }
    String path = uriTemplate != null ? uriTemplate : basePath;
    endpoint.setHeaderFilterStrategy(new HttpRestHeaderFilterStrategy(path, queryParameters));
    return endpoint.createProducer();
}
Also used : HttpRestHeaderFilterStrategy(org.apache.camel.http.common.HttpRestHeaderFilterStrategy)

Aggregations

HttpRestHeaderFilterStrategy (org.apache.camel.http.common.HttpRestHeaderFilterStrategy)3