User would like to implement a CRUD-API exposed over HTTP.
The purpose of this experience is to demonstrate how a developer can quickly implement a “CRUD” application using the Obsidian platform. The application is using a database to store the managed items. The API has been designed to be simple and intuitive.
The experience is built upon an application to manage fruits. The user experience is delivered using a web page proposing the CRUD operations (create / retrieve / update and delete). The user can also use the service endpoint directly.
While this experience does not showcase a fully-matured RESTful model (level 3), it uses HTTP verbs and status.
HTTP API, CRUD, Database
To get started with this quickstart you'll need the following prerequisites:
Name | Description | Version |
---|---|---|
java | Java JDK | 8 |
maven | Apache Maven | 3.2.x |
oc | OpenShift Client Tools | v3.3.x |
git | Git version management | 2.x |
The project uses Wildfly Swarm to create and package the service.
Execute the following maven command:
mvn clean install
-
Run the following command to start the maven goal of WildFlySwarm:
mvn wildfly-swarm:run
-
If the application launched without error, use the following command to access the web interface to view and modify the data in the database:
http http://localhost:8080/
-
Go to OpenShift Online to get the token used by the oc client for authentication and project access.
-
On the oc client, execute the following command to replace MYTOKEN with the one from the Web Console:
oc login https://api.dev-preview-int.openshift.com --token=MYTOKEN
- Start the PostgreSQL database on Openshift
oc new-app -e POSTGRESQL_USER=swarm -ePOSTGRESQL_PASSWORD=password -ePOSTGRESQL_DATABASE=fruits openshift/postgresql-92-centos7 --name=my-database
This will create a database pod with the name my-database
-
Use the Fabric8 Maven Plugin to launch the S2I process on the OpenShift Online machine & start the pod.
mvn clean fabric8:deploy -Popenshift -DskipTests
-
Get the route url.
oc get route/swarm-rest-jdbc NAME HOST/PORT PATH SERVICE TERMINATION LABELS swarm-rest-jdbc <HOST_PORT_ADDRESS> swarm-rest-jdbc:8080
-
Access the web interface to modify the data in the postgres database.
http://<HOST_PORT_ADDRESS>/