OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Camel Get Confused REST - URL param


Hi

Its the restlet framework that picks the wrong one. Flip the order of
your operations in the rest-dsl so the static ones come before the
dynamic ones (eg {xxx}).

There is some JIRA tickets about this in the issue tracker.

On Mon, Mar 19, 2018 at 10:52 PM, Renato Barros <renalexster@xxxxxxxxx> wrote:
> Hi folks,
>
> I'm using Camel Rest (with *restlet* component) and I have the following
> APIs:
>
> rest("/order")
> .get("/{*orderId*}").produces("application/json")
> .param().dataType("int").type(RestParamType.path).name("orderId").endParam()
> .route()
> .bean(OrderService.class, "findOrderById")
> .endRest()
>
>
> .get("/*customer*").produces("application/json").route()
> .bean(OrderService.class, "findOrderByCustomerId")
> .endRest()
>
> The problem is that the */order/customer* doesn't works (see Exception
> below). *The parameters for /customer comes from JWT*...
>
> java.lang.String to the required type: java.lang.Long with value customer
> due Illegal characters: customer
>
> I think that camel is confusing the ../{orderId} parameter with
> .../customer.
> If I change the /customer for /customer/orders it's works.
>
> The same idea in Spring Boot could have done with:
>
> @RequestMapping("/order/{*orderId*}")
> public Order getOrder(@PathVariable Long orderId) {
> return orderRepo.findOne(orderId);
> }
> @RequestMapping("/order/*customer*")
> public List<Order> getOrder() {
> return orderRepo.listOrderByCustomer(1l);
> }
>
>
> Any idea about what's happening?



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2