Getting Started
Creating a new Project
We use Maven Archetypes to generate a template for you to get started.
First, create a directory called GLProjects
:
Next, run the following command to create a new starter project:
You will then be prompted to fill out some information:
Hit "Y" to finish generating your new project.
This will generate a new GreenLightning project for us to start coding. Open up the project in your favorite IDE (such as IntelliJ IDEA or Eclipse) and navigate to the src/main/java/com.ociweb
folder:
GreenLightning.java
- This file is responsible for spinning up a new GreenLightning runtime and can be ignored for the rest of this tutorial.RestServer.java
- This is the main file we will work with. It will setup our HTTP server, connect behaviors and routes, and configure connection settings.HelloField.java
- This will contain enums required for field identification.HelloStruct.java
- This will contain enums for route identification.
Setting up a HTTP Server
GreenLighting allows you to use a lot of different servers - you're not just limited to HTTP. In this example, we will be using HTTP, so we need to specify and create our HTTP 1.x server.
Open up RestServer.java
. It should look something like this: