Hello world, but straight to the cloud

Next

Goal

We want to host on Poja a Spring Boot Application that exposes the /hello endpoint, for which it answers ... world!.

How-to in 2 steps

Step 1: Create your application

From the Applications page, click on the Create New button, then:

  1. Provide the name of the application

  2. Provide the Github account where Poja will create the Github repository to put your Poja-generated starter template

  3. Provide the package name, say com.my.company. The starter template code will be generated in that package.

  4. Provide the name and description of the to-create Github repository. The repository name may differ from the application name.

  5. Save. Wait. And voilà! Your application will be deployed automatically.

/ping

Every generated starter template comes with a /ping endpoint. To test your deployment, go to the generated deployment URL, then /ping it… and it will pong !

Step 2: Code your endpoint

In the generated Poja starter template, controllers are located in com.my.company.endpoint.rest.controller

package com.my.company.endpoint.rest.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {

  @GetMapping("/hello")
  public String helloWorld() {
    return "... world!";
  }
}

Important !

Do not forget to properly format your code before pushing it the prod or preprod branch, otherwise, the deployment will fail
Windows: run .\format.bat

MacOS & Linux: run ./format.sh

To trigger a deployment, just commit and push the code to the preprod branch of the repository. Wait. And voilà!