Leap Quickstart Guide

By the end of this guide, you will have created your first Leap Feature and have a working HTTP Endpoint that you can communicate with. For a more in-depth example, see our First Integration Guide (coming soon) where we use Leap to a bridge between two applications.

Before following this guide, make sure to set up the Leap CLI

Setup Leap Project Using Leap CLI

Now that you have configured the Leap CLI, creating your first Leap Feature is just a few moments away!

Create a Directory for the Project

# Pick any Directory where you'd like to create your project
# For this demo let's create the "intro" folder

mkdir intro

Initialize Project Structure and Database

Before starting this step, make sure you’ve installed the recommended version of MySQL mentioned in the Leap CLI Guide.

# move into our new "intro" directory
cd intro

# Leap CLI to initialize
leap-cli -init "local" -configDB "introschema"

Verify that the Project and Database are configured correctly

Verify Configuration

If Leap CLI was successful you will see a directory structure that looks just like the image below.

For the purpose of this guide, you only need to pay attention to the /config and /services directories. That is where we will making our customizations in the upcoming steps.

leap directory structure
Directory Structure Example

The next thing you should check is that the schema “introschema” was created and has the required Leap tables present. See the screenshot below for reference.

database schema example

Create Your First Feature

Update Framework Configuration

Since we are using a custom schema in our Database – to isolate this protects our data from other Leap Projects – the CLI has automatically updated the globalAppDeploymentConfig.properties file to let the framework know which schema to use when talking with the Database. By default, Leap uses a schema named “leap”. Instead, the CLI has updated the DB_URL to use the schema name to “introschema”.

File to update config
file: attunedlabs/config/local/globalAppDeploymentConfig.properties

Create a New Feature

# Create a new Feature within the Project

# -a "intro" is the name of the folder in /services
# -g "com.attunedlabs" is the maven groupId to use
# -fg "testing" is the name of the Feature Group of the Feature
# -fn "first" is the name of the Feature we're creating
# -impl "welcome" is the specific name for this Feature implementation
# -ven "attunedlabs" is the vendor of the Feature
# -p "local" causes the build to occur for your local environment

leap-cli –a “intro” –g “com.attunedlabs” –fg “testing” –fn “first” –impl “welcome” –ven “attunedlabs” –p “local”

Once this command has finished, we’ve created a new Maven project called “intro” that contains a Leap Feature named “first”, which belongs to a logical group called “testing” that may also contain other Features. It may take some time to finish as the project will automatically build after adding a new Feature.

Because a Feature implementation could vary per tenant in a multi-tenant deployment, the implementation name “welcome” is used to identify our particular Feature.

If you take a peek at the /services directory, you will see the new folder “intro” listed.

Tweaking the New Service

Change the Service Output

Now that our new Feature is created, it’s time for us to make our mark and create a custom service. We’ll test this server as well as the default service in the last step.

Navigate to: /attunedlabs/services/intro/src/main/resources/meta-inf/spring/first-welcome-impl.xml and edit the text inside of the <simple> tags. In this case I’m simply appending “world” to the end of the text “hello” that is already present.

<!-- first-welcome-impl.xml -->

<route id="hello-world-implEnrchimentRoute">
        <from uri="direct:first-hello-world-ImplementationEnrichmentRoute"/>
        <to uri="direct:first-hello-world-IR"/>
<route id="hello-world-implRoute">
	<from uri="direct:first-hello-world-IR"/>
		<simple>Hello World</simple>
	<to uri="direct:first-hello-world-executionExitRoute"/>

When calling this web service, the text “Hello World” will be returned

Build & Run the Project

Because of the edit in the Feature Implementation file, we must build the Feature again and then run it. Just to be certain everything is working properly, we’ll build the entire project before running.

# Build Leap Project from /attunedlabs/services directory

leap-cli -build "local"

This build may take a little while to complete, once it has finished, we can try the run command to start the Leap Framework in our command line and make our new Feature available.

# Run Leap Project from /attunedlabs/services

leap-cli -run

If the framework was successfully started, you should see something like the image below in your command line.

Final Few Lines of Successful Leap “Run” command

Testing Your Leap Feature

You can use any application you’d like for testing the endpoint, but, in this guide, we’ll be using Postman.

Simply start a new HTTP GET request with the following details and press “Send”:

  • Headers
    • accountId = ALL
    • siteId = all
  • URL
    • localhost:9060/ecomm/rest/testing/first/hello-world

The Leap URL standard format is composed based on the exact service you’d like to access. The general format is as follows:

/ecomm/ <rest | json | xml> / <featureGroup> / <featureName> / <serviceName>

Leap URL Format

In the example below, we’re calling our service “hello-world” and setting the appropriate header values. Although they are not used in this case, these headers act as a hint to tell Leap which service to call when Leap is running in a multi-tenant environment.

If your Feature was created successfully and is currently running, you will see the same result as the image below.

example of the HTTP request to make

Next Steps:

The next step in your Leap adventure will teach you how to call a Bean from your services and interact with incoming data.

Updated on September 7, 2021

Was this article helpful?

Related Articles