You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/01/11 16:28:58 UTC

[GitHub] [camel-k] juliuskrah opened a new issue #2867: Using REST as consumer and producer appends PATH to producer URL

juliuskrah opened a new issue #2867:
URL: https://github.com/apache/camel-k/issues/2867


   Camel K: `1.7.0`
   Dependencies: `camel-jackson`, `camel-netty-http`
   
   I built an integration using `rest component` that serves as a consumer and also a producer:
   
   primeValidator.groovy
   
   ```groovy
   // camel-k: language=groovy dependency=camel:jackson dependency=camel:netty-http property=file:application.properties
   
   rest {
       path('/validate') {
           post {
               consumes 'application/json'
               produces 'application/json'
               to 'direct:postToPrime'
           }
       }
   }
     
   from('direct:postToPrime')
       .process { 
           it.in.body = [
               username: it.context.resolvePropertyPlaceholders('{{prime.username}}'), 
               password: it.context.resolvePropertyPlaceholders('{{prime.password}}')
           ] 
       }
       .marshal().json()
       .log(org.apache.camel.LoggingLevel.INFO, 'com.example.validation.PrimeValidation', 'JSON produced: ${body}')
       .to('rest://post:{{prime.auth-path}}?host={{prime.base-url}}&routeId=primeAuthenticate')
       .to('log:com.example.validation.PrimeValidation?level=INFO')
   ```
   
   application.properties
   
   ```properties
   prime.username=user
   prime.password=pass
   prime.base-url=https://example.prime.com
   prime.auth-path=api/auth
   
   camel.component.netty-http.client-mode=true
   camel.rest.component=platform-http
   camel.rest.producer-component=netty-http
   camel.rest.client-request-validation=true
   camel.rest.binding-mode=json
   camel.rest.host=0.0.0.0
   camel.rest.port=8080
   
   camel.component.rest.consumerComponentName=platform-http
   ```
   
   ```bash
   > kamel run --dependency camel-jackson --dependency camel-netty-http --property file:application.properties --trait service.node-port=false primeValidator.groovy --dev
   > kubectl port-forward service/prime-validator 8080:80
   > curl --location --request POST 'localhost:8080/validate' \
   --header 'Content-Type: application/json' \
   --data-raw '{
       "name": "julius"
   }'
   ```
   
   Expectation: Producer request should be sent to `https://example.prime.com/api/auth`
   
   Actual behaviour: Producer request is sent to `https://example.prime.com/api/auth/validate`. 
   
   > :warning: **Note `validate` is appended**


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-k] JPMoresmau commented on issue #2867: Using REST as consumer and producer appends PATH to producer URL

Posted by GitBox <gi...@apache.org>.
JPMoresmau commented on issue #2867:
URL: https://github.com/apache/camel-k/issues/2867#issuecomment-1032608532


   Calling `.removeHeaders("CamelHttpPath")` before the second rest call solved this issue for me


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org