Quick Start

In this guide, we are going to create a sample HTTP service. You can read the Core or HTTP Server modules documentation for more information. You can use both Gradle and Maven to build your application.

You can start by cloning a starter project (Gradle Starter or Maven Starter). Or you can create a project from scratch following these steps:

  1. Configure Kotlin in Gradle or Maven.
  2. Add the dependency in Gradle or Maven:
1
2
3
4
5
repositories {
    mavenCentral()
}

implementation("com.hexagonkt:http_server_jetty:$hexagonVersion")
1
2
3
4
5
<dependency>
  <groupId>com.hexagonkt</groupId>
  <artifactId>http_server_jetty</artifactId>
  <version>$hexagonVersion</version>
</dependency>
  1. Write the code in the src/main/kotlin/Hello.kt file:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
package com.hexagonkt.http.server.jetty

import com.hexagonkt.http.server.Server

lateinit var server: Server

fun main() {
    server = Server(JettyServletAdapter()) {
        get("/hello") {
            ok("Hello World!")
        }
    }

    server.start()
}
  1. Run the service and view the results at: http://localhost:2010/hello/world

Tip

If you use Gradle, you can use the Application Helper and run the application watching for changes with the command: ./gradlew watch -t

Dependencies Verification

Hexagon's dependencies are signed, you can get the public key at the OpenPGP Public Key Server or here.

These are the details of the public key:

1
2
pub  4096R/2AEE3721 2020-05-30 Hexagon Toolkit (Key used to sign published binaries) <project@hexagonkt.com>
     Fingerprint=792B D37F F598 91C4 AC6F  8D92 3B26 711D 2AEE 3721

Warning

You may find a deprecated public key in public GPG key servers (check the details below). Please, ignore it and use the above one. The information about the obsolete is:

1
2
pub  2048R/657676D1 2020-05-30 Hexagon Toolkit <project@hexagonkt.com>
     Fingerprint=F263 9BBC 4A6A FE50 D098  9F08 5352 7033 6576 76D1

Next Steps

To continue learning about this toolkit, you can:

Comments