## Apache Camel Example using Servlet REST & Web Container

This example shows how to use Servlet REST to define REST endpoints in Camel routes using the Rest DSL
This example is implemented in both the Java and XML DSLs. By default the Java DSL is in use. You can change this in the src/main/webapps/WEB-INF/web.xml file
For Java DSL the routes are defined in Java code, in the `org.apache.camel.example.rest.UserRouteBuilder` class. And for XML DSL the routes are define in XML code, in the `src/main/resources/camel-config-xml.xml` file.

There is a user REST service that supports the following operations

- GET /user/{id} - to view a user with the given id
- GET /user/final - to view all users
- PUT /user - to update/create an user

The view operations are HTTP GET, and update is using HTTP PUT. From a web browser you can access the first two services using the following links

- user/123 - to view the user with id 123
- user/findAll - to list all users

From the command shell you can use curl to access the service as shown below:

        curl -X GET -H "Accept: application/json" http://localhost:8080/camel-example-servlet-rest-tomcat/rest/user/123
        curl -X GET -H "Accept: application/json" http://localhost:8080/camel-example-servlet-rest-tomcat/rest/user/findAll
        curl -X PUT -d "{ \"id\": 666, \"name\": \"The devil\"}" -H "Accept: application/json" http://localhost:8080/camel-example-servlet-rest-tomcat/rest/user

Notice when trying to get user with id 789 then there is a built-in delay of 0.5-2 seconds, to simulate some slowness in the service.

This example offers an API browser using Swagger which is accessible from the following link

- api-docs - overview of the apis from the REST services
- api-docs/user - api of the user REST service

To use the swagger ui, follow this link. Replace the URL value with this one to access the REST local resources (http://localhost:8080/api-docs or (http://localhost:8080/camel-example-servlet-rest-tomcat/api-docs when deployed in Apache Tomcat)

- swagger - swagger ui page

If you hit any problems please let us know on the Camel Forums
Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
The Camel riders!