This example implements a simple Hello World REST service using MicroProfile and shows how to deploy it to Google App Engine.
With JDK11
mvn package
java -jar target/helidon-quickstart-mp.jar
curl -X GET http://localhost:8080/greet
{"message":"Hello World!"}
curl -X GET http://localhost:8080/greet/Joe
{"message":"Hello Joe!"}
curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting
curl -X GET http://localhost:8080/greet/Jose
{"message":"Hola Jose!"}
curl -s -X GET http://localhost:8080/health
{"outcome":"UP",...
. . .
# Prometheus Format
curl -s -X GET http://localhost:8080/metrics
# TYPE base:gc_g1_young_generation_count gauge
. . .
# JSON Format
curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
{"base":...
. . .
Pick a project ID for your project and save it in an environment variable:
export YOUR_PROJECT_ID=[your_project_id]
Replace [your_project_id]
with a string of characters that uniquely identifies your project.
For example, my-helidon-project-44
Go to the Google App Engine Quickstart for Java 11: and complete the steps under "Before You Begin". Stop when you reach "Download the Hello World app".
Verify your project:
gcloud projects describe $YOUR_PROJECT_ID
If you haven't already done it, build the Helidon example locally:
mvn package
Then deploy it to Google App Engine
gcloud app deploy target/helidon-mp-app.yaml
This will upload files, then deploy the service.
You can view the application in your browser by running:
gcloud app browse
The browser will initially report "No handler found for path: /". That's OK.
You can now exercise the application by modifying the URL to match what was described earlier in this README. For example append `/greet/ to the URL.
- This example responds to the
PORT
environment variable as provided by the Google App Engine runtime. - By default Helidon packages your application as a "thin" jar file with runtime dependencies
external to the jar (in
libs
). The jar file'sMETA-INF/MANIFEST.MF
hasMain-Class
andClass-Path
set appropriately. Google App Engine supports this packaging as long as you use a custom entrypoint as is done intarget/helidon-mp-app.yaml
. - To control what files are uploaded we have
src/main/gae/.gcloudignore
that gets copied into the target directory. It excludes everything, and then includes only what is needed.
Make sure to cleanup your application as described in the Google App Engine Quickstart.