The example project shows how you can use Knot.x and develop it in a real project. Uses the Knot.x Stack distribution and provides custom configuration files, sample content and modules.
- JDK 8+
- Maven or Gradle
The example project consists of:
acme-stack
- contains all configuration files and the sample contentacme-action-adapter-http
- handles forms submit requests (POSTs), executes business logic and redirects to the next step / confirmation page / stay on the same pageacme-gateway
- provides the Gateway API interface that can be used by front-end integrationacme-handlebars-ext
- adds custom Handlebars directivesacme-sample-service
- runs the HTTP server on the3000
port, which mocks real JSON service responses
The acme-stack
module contains all required artifacts to build the example distribution. The result
of the build process is a ZIP file that you can deploy to the server, extract and run with
bin\knotx run-knotx
. The run-knotx
command starts all Knot.x modules, configures logs, and sets
Java options. Note that all dependencies like acme-action-adapter-http
, acme-gateway
,
acme-handlebars-ext
and acme-sample-service
are build and copied to the distribution.
Clone the repository and build the example project:
Let's run the command below:
$> mvn package
The distribution ZIP file location is acme-stack/target/knotx-example-project-stack-X.X.X.zip
.
Let's run the command below:
$> gradlew
The distribution ZIP file location is acme-stack/build/distributions/knotx-example-project-stack-X.X.X.zip
- Download and unpack latest knotx-example-project-stack or
- clone the repository and build the example project
Go to the acme-stack
folder in the unpacked zip file and run the Knot.x script
$> bin/knotx run-knotx
$> bin\knotx.bat run-knotx
Build image from dockerfile being in the knotx-example-project
folder
$> docker build -t acme/knotx-example .
Run Knot.x container in background
$> docker run -d -p8092:8092 acme/knotx-example knotx-example
Follow logs
$> docker logs -f knotx-example
Clone this repository and go to acme-cluster
folder and run the Knot.x cluster
$> docker-compose up
Knot.x works in two modes:
- templating engine with custom business logic that integrates with any data source using Knot.x Data Bridge and Handlebars (back-end integration)
- Gateway mode providing REST API (front-end integration)