You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Federico Trotto <tr...@gmail.com> on 2020/11/23 02:12:22 UTC
How to use the context Path in Camel routes?
i am new to camel. i am doing a project in spring-boot using camel for
routes. I noticed that when I go to SwaggerUi to see the correct
functioning of my Post calls the contextPath of the routes does not work:
public void configure() {
restConfiguration().component("servlet").contextPath("service/");
rest("/ocs")
.post("/homologation")
.id(camelRoutesIdConfig.getHomologationRequestRouteId())
.consumes("application/json")
.produces("application/json")
.param()
.name("IntegrationRequestDto")
.type(RestParamType.body)
.required(true)
.description("attivazione nuovo contratto sul portale")
.endParam()
.to("direct:homologation")
}
This problem does not occur if in the application.yml I specify the
contextPath like this:
camel:
rest:
component: servlet
binding-mode: json
enable-cors: true
data-format-property:
prettyPrint: false
component:
servlet:
mapping:
context-path: /service/*
When I make my call Post in one case it works, while in the case of
ContextPath in routes it doesn't recognize the command and gives
{
"timestamp": "2020-11-22T17:44:26.701+0000",
"status": 404,
"error": "Not Found",
"message": "Not Found",
"path": "/service/ocs/homologation"
}
Why is there this problem? Why am I forced to also specify in the
application.yml instead of using it only once in the routes? Thanks to
everyone for a possible answer
Re: How to use the context Path in Camel routes?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Because how servlets work. For example if you develop a web app (as
war) then you cannot via code configure the servlet mappings, you
specify those in the web.xml).
spring-boot may give a little opportunity to do this, but its there
are many other servlet runtimes, so you cannot make it general.
On Mon, Nov 23, 2020 at 7:59 AM Federico Trotto
<tr...@gmail.com> wrote:
>
> i am new to camel. i am doing a project in spring-boot using camel for
> routes. I noticed that when I go to SwaggerUi to see the correct
> functioning of my Post calls the contextPath of the routes does not work:
>
> public void configure() {
>
> restConfiguration().component("servlet").contextPath("service/");
>
> rest("/ocs")
> .post("/homologation")
> .id(camelRoutesIdConfig.getHomologationRequestRouteId())
> .consumes("application/json")
> .produces("application/json")
> .param()
> .name("IntegrationRequestDto")
> .type(RestParamType.body)
> .required(true)
> .description("attivazione nuovo contratto sul portale")
> .endParam()
> .to("direct:homologation")
>
> }
>
> This problem does not occur if in the application.yml I specify the
> contextPath like this:
>
> camel:
> rest:
> component: servlet
> binding-mode: json
> enable-cors: true
> data-format-property:
> prettyPrint: false
> component:
> servlet:
> mapping:
> context-path: /service/*
>
> When I make my call Post in one case it works, while in the case of
> ContextPath in routes it doesn't recognize the command and gives
>
> {
> "timestamp": "2020-11-22T17:44:26.701+0000",
> "status": 404,
> "error": "Not Found",
> "message": "Not Found",
> "path": "/service/ocs/homologation"
> }
>
> Why is there this problem? Why am I forced to also specify in the
> application.yml instead of using it only once in the routes? Thanks to
> everyone for a possible answer
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2