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-forms-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 responsesknotx-databridge
- modules which extends Knot.x Data Bridgeacme-db-datasource-adapter
- a sample JDBC Data Source Adapter to demonstrate how to implement and configure custom Data Source Adapters in Data Bridge (contains a docker image with a sample HSQLDB database instance)
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-forms-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 Forms,
Knot.x Data Bridge and
Handlebars (back-end integration)
- http://localhost:8092/content/simple.html
- http://localhost:8092/content/login/step1.html
- http://localhost:8092/content/multiple-forms.html
- http://localhost:8092/content/db-books.html Note: to have it working you need to run your local HSQLDB instance. More details can be found here.
- Gateway mode providing REST API (front-end integration)