diff --git a/examples/config/basics/README.md b/examples/config/basics/README.md index 1031407da92..f946aa5910b 100644 --- a/examples/config/basics/README.md +++ b/examples/config/basics/README.md @@ -10,7 +10,7 @@ containing config in HOCON (Human-Optimized Config Object Notation) format ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-config-basics.jar ``` diff --git a/examples/config/changes/README.md b/examples/config/changes/README.md index ca4e4a58871..2f290e98baa 100644 --- a/examples/config/changes/README.md +++ b/examples/config/changes/README.md @@ -23,7 +23,7 @@ the most up-to-date value. Sometimes that is all you need. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-config-changes.jar ``` diff --git a/examples/config/git/README.md b/examples/config/git/README.md index 4b73456ffcc..efa442e8f3b 100644 --- a/examples/config/git/README.md +++ b/examples/config/git/README.md @@ -21,7 +21,7 @@ checks to make sure the value is the expected `hello`. ## Build and run -```bash +```shell mvn package export ENVIRONMENT_NAME=test java -jar target/helidon-examples-config-git.jar diff --git a/examples/config/mapping/README.md b/examples/config/mapping/README.md index 05e060f6421..12523332066 100644 --- a/examples/config/mapping/README.md +++ b/examples/config/mapping/README.md @@ -17,7 +17,7 @@ system how to construct a POJO instance. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-config-mapping.jar ``` diff --git a/examples/config/metadata/README.md b/examples/config/metadata/README.md index 9e9448c8ee3..7057c721321 100644 --- a/examples/config/metadata/README.md +++ b/examples/config/metadata/README.md @@ -18,7 +18,7 @@ Example: ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-config-metadata.jar > application.yaml ``` diff --git a/examples/config/overrides/README.md b/examples/config/overrides/README.md index 3d539e3fec9..966a6435d3b 100644 --- a/examples/config/overrides/README.md +++ b/examples/config/overrides/README.md @@ -21,7 +21,7 @@ take precedence over the settings in the original config sources. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-config-overrides.jar ``` diff --git a/examples/config/sources/README.md b/examples/config/sources/README.md index 65cb26ebb3c..cfb5c321080 100644 --- a/examples/config/sources/README.md +++ b/examples/config/sources/README.md @@ -17,7 +17,7 @@ filter. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-config-sources.jar ``` diff --git a/examples/cors/README.md b/examples/cors/README.md index 6fdaab0eba3..0216c09bc4b 100644 --- a/examples/cors/README.md +++ b/examples/cors/README.md @@ -14,16 +14,16 @@ uncomment that line and then package and run the application. ## Build and run -```bash +```shell mvn package -java -jar helidon-examples-cors.jar +java -jar target/helidon-examples-cors.jar ``` ## Using the app endpoints as with the "classic" greeting app These normal greeting app endpoints work just as in the original greeting app: -```bash +```shell curl -X GET http://localhost:8080/greet {"message":"Hello World!"} @@ -45,7 +45,7 @@ The following requests illustrate the CORS protocol with the example app. By setting `Origin` and `Host` headers that do not indicate the same system we trigger CORS processing in the server: -```bash +```shell # Follow the CORS protocol for GET curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet @@ -63,8 +63,17 @@ Note the new headers `Access-Control-Allow-Origin` and `Vary` in the response. The same happens for a `GET` requesting a personalized greeting (by passing the name of the person to be greeted): -```bash +```shell curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet/Joe + +HTTP/1.1 200 OK +Date: Wed, 31 Jan 2024 11:58:06 +0100 +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Length: 24 +Content-Type: application/json +Vary: ORIGIN + {"greeting":"Hola Joe!"} ``` These two `GET` requests work because the `Main#corsSupportForGreeting` method adds a default `CrossOriginConfig` to the @@ -83,7 +92,7 @@ The CORS protocol requires the client to send a _pre-flight_ request before send This command sends a pre-flight `OPTIONS` request to see if the server will accept a subsequent `PUT` request from the specified origin to change the greeting: -```bash +```shell curl -i -X OPTIONS \ -H "Access-Control-Request-Method: PUT" \ -H "Origin: http://foo.com" \ @@ -91,16 +100,17 @@ curl -i -X OPTIONS \ http://localhost:8080/greet/greeting HTTP/1.1 200 OK +Date: Wed, 31 Jan 2024 12:00:15 +0100 Access-Control-Allow-Methods: PUT Access-Control-Allow-Origin: http://foo.com -Date: Thu, 30 Apr 2020 17:30:59 -0500 -transfer-encoding: chunked -connection: keep-alive +Access-Control-Max-Age: 3600 +Connection: keep-alive +Content-Length: 0 ``` The successful status and the returned `Access-Control-Allow-xxx` headers indicate that the server accepted the pre-flight request. That means it is OK for us to send `PUT` request to perform the actual change of greeting. (See below for how the server rejects a pre-flight request.) -```bash +```shell curl -i -X PUT \ -H "Origin: http://foo.com" \ -H "Host: here.com" \ @@ -111,14 +121,24 @@ curl -i -X PUT \ http://localhost:8080/greet/greeting HTTP/1.1 204 No Content +Date: Wed, 31 Jan 2024 12:01:45 +0100 Access-Control-Allow-Origin: http://foo.com -Date: Thu, 30 Apr 2020 17:32:55 -0500 -Vary: Origin -connection: keep-alive +Connection: keep-alive +Content-Length: 0 +Vary: ORIGIN ``` And we run one more `GET` to observe the change in the greeting: -```bash +```shell curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet/Joe + +HTTP/1.1 200 OK +Date: Wed, 31 Jan 2024 12:02:13 +0100 +Access-Control-Allow-Origin: * +Connection: keep-alive +Content-Length: 26 +Content-Type: application/json +Vary: ORIGIN + {"greeting":"Cheers Joe!"} ``` Note that the tests in the example `MainTest` class follow these same steps. @@ -131,38 +151,38 @@ need this feature, but the example shows how easy it is to add. With the same server running, repeat the `OPTIONS` request from above, but change the `Origin` header to refer to `other.com`: -```bash +```shell curl -i -X OPTIONS \ -H "Access-Control-Request-Method: PUT" \ -H "Origin: http://other.com" \ -H "Host: here.com" \ http://localhost:8080/greet/greeting -HTTP/1.1 403 Forbidden -Date: Mon, 4 May 2020 10:49:41 -0500 -transfer-encoding: chunked -connection: keep-alive +HTTP/1.1 403 CORS origin is not in allowed list +Date: Wed, 31 Jan 2024 12:02:51 +0100 +Connection: keep-alive +Content-Length: 0 ``` This fails because the app set up CORS using the "restrictive-cors" configuration in `application.yaml` which allows sharing only with `foo.com` and `there.com`, not with `other.com`. Stop the running app, uncomment the commented section at the end of `application.yaml`, and build and run the app again. -```bash +```shell mvn package -java -jar helidon-examples-cors.jar +java -jar target/helidon-examples-cors.jar ``` Send the previous `OPTIONS` request again and note the successful result: -```bash +```shell HTTP/1.1 200 OK +Date: Wed, 31 Jan 2024 12:05:36 +0100 Access-Control-Allow-Methods: PUT Access-Control-Allow-Origin: http://other.com Access-Control-Max-Age: 3600 -Date: Mon, 4 May 2020 18:52:54 -0500 -transfer-encoding: chunked -connection: keep-alive +Connection: keep-alive +Content-Length: 0 ``` The application uses the now-uncommented portion of the config file to override the rest of the CORS set-up. You can choose whatever key name you want for the override. Just make sure you tell your end users whatever the key is your app uses for overrides. A real application might read the normal configuration (`restrictive-cors`) from one config source and any overrides -from another. This example combines them in one config source just for simplicity. \ No newline at end of file +from another. This example combines them in one config source just for simplicity. diff --git a/examples/dbclient/README.md b/examples/dbclient/README.md index db4dc973ba4..5345384f745 100644 --- a/examples/dbclient/README.md +++ b/examples/dbclient/README.md @@ -3,6 +3,12 @@ Each subdirectory contains example code that highlights specific aspects of Helidon DB Client. +build examples in all folders (including the common folder) by +```shell +mvn package +``` +in the current folder. + --- Pokémon, and Pokémon character names are trademarks of Nintendo. diff --git a/examples/dbclient/common/README.md b/examples/dbclient/common/README.md new file mode 100644 index 00000000000..875f95c9232 --- /dev/null +++ b/examples/dbclient/common/README.md @@ -0,0 +1,22 @@ +# Common library for the DB Client examples + +shall be built using + +```shell + +mvn install + +``` + +to be accessible for the DB Client examples + +or make the whole pack of DB Client examples at the level above by + +```shell + +cd ../ +mvn package + +``` + +and get all DB Client examples compiled at once. \ No newline at end of file diff --git a/examples/dbclient/mongodb/README.md b/examples/dbclient/mongodb/README.md index fc9873b743e..307cab3a83a 100644 --- a/examples/dbclient/mongodb/README.md +++ b/examples/dbclient/mongodb/README.md @@ -24,7 +24,7 @@ java -jar target/helidon-examples-dbclient-mongodb.jar ``` -## Exercise +## Exercise The application has the following endpoints: diff --git a/examples/dbclient/pokemons/README.md b/examples/dbclient/pokemons/README.md index a2ebdf2a817..58564d0f77f 100644 --- a/examples/dbclient/pokemons/README.md +++ b/examples/dbclient/pokemons/README.md @@ -1,8 +1,8 @@ -# Helidon DB Client Pokemon Example with JDBC +# Helidon DB Client Pokémon Example with JDBC This example shows how to run Helidon DB Client over JDBC. -Application provides REST service endpoint with CRUD operations on Pokemons +Application provides REST service endpoint with CRUD operations on Pokémons database. ## Database @@ -24,7 +24,7 @@ Database model contains two tables: | name | varchar |   | | id_type | integer | Type(id) | -with 1:N relationship between *Types* and *Pokemons* +with 1:N relationship between *Types* and *Pokémons* Examples are given for H2, Oracle, or MySQL databases (note that MySQL is currently not supported for GraalVM native image) diff --git a/examples/employee-app/README.md b/examples/employee-app/README.md index e3af9fd6fcd..e607a8b2fb9 100644 --- a/examples/employee-app/README.md +++ b/examples/employee-app/README.md @@ -13,9 +13,9 @@ The service uses Helidon DB Client to access the database. ## Build and run -```bash +```shell mvn package -java -jar target/employee-app.jar +java -jar target/helidon-examples-employee-app.jar ``` ## Create script @@ -290,4 +290,4 @@ INSERT INTO EMPLOYEE (ID, FIRSTNAME, LASTNAME, EMAIL, PHONE, BIRTHDATE, TITLE, D INSERT INTO EMPLOYEE (ID, FIRSTNAME, LASTNAME, EMAIL, PHONE, BIRTHDATE, TITLE, DEPARTMENT) VALUES (EMPLOYEE_SEQ.nextVal, 'Zora', 'Sawayn', 'Zora.Sawayn@example.com', '923-555-0161', '1978-03-18', 'Dynamic Marketing Designer', 'Security'); INSERT INTO EMPLOYEE (ID, FIRSTNAME, LASTNAME, EMAIL, PHONE, BIRTHDATE, TITLE, DEPARTMENT) VALUES (EMPLOYEE_SEQ.nextVal, 'Cordia', 'Willms', 'Cordia.Willms@example.com', '778-555-0187', '1989-03-31', 'Human Division Representative', 'Optimization'); -``` +``` \ No newline at end of file diff --git a/examples/graphql/basics/README.md b/examples/graphql/basics/README.md index 3e39e8d945b..eb43abe7996 100644 --- a/examples/graphql/basics/README.md +++ b/examples/graphql/basics/README.md @@ -7,7 +7,7 @@ manually creates a GraphQL Schema using the [GraphQL Java](https://github.com/gr Start the application: -```bash +```shell mvn package java -jar target/helidon-examples-graphql-basics.jar ``` @@ -18,7 +18,7 @@ Probe the GraphQL endpoints: 1. Hello word endpoint: - ```bash + ```shell curl -X POST http://127.0.0.1:PORT/graphql -d '{"query":"query { hello }"}' "data":{"hello":"world"}} @@ -26,7 +26,7 @@ Probe the GraphQL endpoints: 1. Hello in different languages - ```bash + ```shell curl -X POST http://127.0.0.1:PORT/graphql -d '{"query":"query { helloInDifferentLanguages }"}' {"data":{"helloInDifferentLanguages":["Bonjour","Hola","Zdravstvuyte","Nǐn hǎo","Salve","Gudday","Konnichiwa","Guten Tag"]}} diff --git a/examples/graphql/basics/src/main/java/io/helidon/examples/graphql/basics/Main.java b/examples/graphql/basics/src/main/java/io/helidon/examples/graphql/basics/Main.java index ba5911e61ab..1be76d49915 100644 --- a/examples/graphql/basics/src/main/java/io/helidon/examples/graphql/basics/Main.java +++ b/examples/graphql/basics/src/main/java/io/helidon/examples/graphql/basics/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023 Oracle and/or its affiliates. + * Copyright (c) 2020, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public static void main(String[] args) { .routing(routing -> routing .register(GraphQlService.create(buildSchema()))) .build(); - + server.start(); String endpoint = "http://localhost:" + server.port(); System.out.printf(""" GraphQL started on %1$s/graphql diff --git a/examples/health/basics/README.md b/examples/health/basics/README.md index 6ae10e5d654..17c690051fa 100644 --- a/examples/health/basics/README.md +++ b/examples/health/basics/README.md @@ -8,7 +8,7 @@ custom health check. Start the application: -```bash +```shell mvn package java -jar target/helidon-examples-health-basics.jar ``` @@ -17,7 +17,7 @@ Note the port number reported by the application. Probe the health endpoints: -```bash -curl -X GET http://localhost:PORT/health/ -curl -X GET http://localhost:PORT/health/ready +```shell +curl -i -X GET http://localhost:8080/observe/health/ready +curl -i -X GET http://localhost:8080/observe/health/ ``` diff --git a/examples/health/basics/src/main/java/io/helidon/examples/health/basics/Main.java b/examples/health/basics/src/main/java/io/helidon/examples/health/basics/Main.java index c4542289b5e..e3b5ef5d796 100644 --- a/examples/health/basics/src/main/java/io/helidon/examples/health/basics/Main.java +++ b/examples/health/basics/src/main/java/io/helidon/examples/health/basics/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023 Oracle and/or its affiliates. + * Copyright (c) 2018, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ public static void main(String[] args) { ObserveFeature observe = ObserveFeature.builder() .observersDiscoverServices(true) .addObserver(HealthObserver.builder() + .details(true) .useSystemServices(true) .addCheck(() -> HealthCheckResponse.builder() .status(HealthCheckResponse.Status.UP) @@ -65,6 +66,7 @@ public static void main(String[] args) { .featuresDiscoverServices(false) .addFeature(observe) .routing(Main::routing) + .port(8080) .build() .start(); diff --git a/examples/inject/README.md b/examples/inject/README.md index 3f91209b293..a5a8fe915ac 100644 --- a/examples/inject/README.md +++ b/examples/inject/README.md @@ -9,3 +9,8 @@ Suggested path to follow: 2. [providers](./providers) 3. [configdriven](./configdriven) 4. [interceptors](./interceptors) + +It's possible to compile all examples in sub-folders using +```shell +mvn package +``` diff --git a/examples/inject/basics/README.md b/examples/inject/basics/README.md index d5ab6a065d6..7b9e68b375f 100644 --- a/examples/inject/basics/README.md +++ b/examples/inject/basics/README.md @@ -10,7 +10,7 @@ This example shows the basics of using Helidon Injection. The ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-inject-basics.jar ``` diff --git a/examples/inject/configdriven/README.md b/examples/inject/configdriven/README.md index 3ca9dfefbf2..00b6e219118 100644 --- a/examples/inject/configdriven/README.md +++ b/examples/inject/configdriven/README.md @@ -10,7 +10,7 @@ This example shows the basics of using Helidon Injection's Config-Driven Service ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-inject-configdriven.jar ``` diff --git a/examples/inject/interceptors/README.md b/examples/inject/interceptors/README.md index 6500a2dadc1..9e01c210d17 100644 --- a/examples/inject/interceptors/README.md +++ b/examples/inject/interceptors/README.md @@ -7,7 +7,7 @@ This example shows how interceptors can be leveraged to develop using Helidon In ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-inject-interceptors.jar ``` diff --git a/examples/inject/providers/README.md b/examples/inject/providers/README.md index 408982af848..57e5fa94f94 100644 --- a/examples/inject/providers/README.md +++ b/examples/inject/providers/README.md @@ -10,7 +10,7 @@ This example shows how providers can be leveraged to develop using Helidon Injec ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-inject-providers.jar ``` diff --git a/examples/integrations/cdi/datasource-hikaricp-h2/README.md b/examples/integrations/cdi/datasource-hikaricp-h2/README.md index 31b6042c9d7..d630d6a6b87 100644 --- a/examples/integrations/cdi/datasource-hikaricp-h2/README.md +++ b/examples/integrations/cdi/datasource-hikaricp-h2/README.md @@ -8,12 +8,12 @@ database. ## Build and run -```bash +```shell mvn package java -jar target/helidon-integrations-examples-datasource-hikaricp-h2.jar ``` Try the endpoint: -```bash +```shell curl http://localhost:8080/tables ``` diff --git a/examples/integrations/cdi/datasource-hikaricp-mysql/README.md b/examples/integrations/cdi/datasource-hikaricp-mysql/README.md index 3c29030a331..14a20bc6484 100644 --- a/examples/integrations/cdi/datasource-hikaricp-mysql/README.md +++ b/examples/integrations/cdi/datasource-hikaricp-mysql/README.md @@ -40,7 +40,7 @@ javax.sql.DataSource.example.dataSource.password = tiger ## Build and run -```bash +```shell mvn package java -jar target/helidon-integrations-examples-datasource-hikaricp-mysql.jar ``` @@ -51,7 +51,7 @@ curl http://localhost:8080/tables ``` Stop the docker container: -```bash +```shell docker stop mysql ``` diff --git a/examples/integrations/cdi/datasource-hikaricp/README.md b/examples/integrations/cdi/datasource-hikaricp/README.md index 7a54e43ff57..cb72a0deeaa 100644 --- a/examples/integrations/cdi/datasource-hikaricp/README.md +++ b/examples/integrations/cdi/datasource-hikaricp/README.md @@ -20,7 +20,7 @@ account if you don't already have one, see To log in to the Oracle Container Registry (which you will need to do in order to download Oracle database Docker images from it): -```bash +```shell docker login -u username -p password container-registry.oracle.com ``` @@ -31,7 +31,7 @@ To run Oracle's `database/standard` Docker image in a Docker container named `oracle` that publishes ports 1521 and 5500 to the host while relying on the defaults for all other settings: -```bash +```shell docker container run -d -it -p 1521:1521 -p 5500:5500 --shm-size=3g \ --name oracle \ container-registry.oracle.com/database/standard:latest @@ -58,7 +58,7 @@ javax.sql.DataSource.example.dataSource.password = Oracle ## Build and run With Docker: -```bash +```shell docker build -t helidon-examples-integrations-datasource-hikaricp . docker run --rm -d \ --link oracle \ @@ -69,17 +69,17 @@ docker run --rm -d \ OR With Maven: -```bash +```shell mvn package java -jar target/helidon-examples-integrations-datasource-hikaricp.jar ``` Try the endpoint: -```bash +```shell curl http://localhost:8080/tables ``` Stop the docker containers: -```bash +```shell docker stop oracle helidon-examples-integrations-datasource-hikaricp ``` diff --git a/examples/integrations/cdi/jpa/README.md b/examples/integrations/cdi/jpa/README.md index c505468b4d8..5a202ed5fd4 100644 --- a/examples/integrations/cdi/jpa/README.md +++ b/examples/integrations/cdi/jpa/README.md @@ -1,13 +1,13 @@ # JPA Integration Example With Java: -```bash +```shell mvn package java -jar target/helidon-integrations-examples-jpa.jar ``` Try the endpoint: -```bash +```shell curl -X POST -H "Content-Type: text/plain" http://localhost:8080/foo -d 'bar' curl http://localhost:8080/foo ``` diff --git a/examples/integrations/cdi/pokemons/README.md b/examples/integrations/cdi/pokemons/README.md index 513acbfbea6..132dd40af58 100644 --- a/examples/integrations/cdi/pokemons/README.md +++ b/examples/integrations/cdi/pokemons/README.md @@ -1,18 +1,22 @@ # JPA Pokemons Example With Java: -```bash +```shell mvn package -java -jar target/helidon-integrations-examples-pokemons-jpa.jar +java -jar target/helidon-integrations-examples-pokemons.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/pokemon -[{"id":1,"type":12,"name":"Bulbasaur"}, ...] +#Output: [{"id":1,"type":12,"name":"Bulbasaur"}, ...] +``` +```shell curl -X GET http://localhost:8080/type -[{"id":1,"name":"Normal"}, ...] +#Output: [{"id":1,"name":"Normal"}, ...] +``` +```shell curl -H "Content-Type: application/json" --request POST --data '{"id":100, "type":1, "name":"Test"}' http://localhost:8080/pokemon ``` diff --git a/examples/integrations/micrometer/mp/README.md b/examples/integrations/micrometer/mp/README.md index a3220b949da..7819c4a0bb3 100644 --- a/examples/integrations/micrometer/mp/README.md +++ b/examples/integrations/micrometer/mp/README.md @@ -22,7 +22,7 @@ The example is similar to the one from the Helidon MP QuickStart with these diff ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-integrations-micrometer-mp.jar ``` @@ -31,24 +31,28 @@ java -jar target/helidon-examples-integrations-micrometer-mp.jar These normal greeting app endpoints work just as in the original greeting app: -```bash +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} +``` +```shell curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"message":"Hello Joe!"} +``` +```shell 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!"} +#Output: {"message":"Hola Jose!"} ``` ## Using Micrometer Access the `/micrometer` endpoint which reports the newly-added timer and counter. -```bash +```shell curl http://localhost:8080/micrometer ``` Because the `@Timer` annotation specifies a histogram, @@ -56,8 +60,10 @@ the actual timer output includes a lengthy histogram (only part of which is show Your output might show the `personalizedGets` output before the `allGets` output, rather than after as shown here. -``` +```shell curl http://localhost:8080/micrometer +``` +```listing # HELP allGets_seconds_max Tracks all GET operations # TYPE allGets_seconds_max gauge allGets_seconds_max 0.004840005 diff --git a/examples/integrations/micrometer/se/README.md b/examples/integrations/micrometer/se/README.md index 3c49e3abc42..2358b4b55f9 100644 --- a/examples/integrations/micrometer/se/README.md +++ b/examples/integrations/micrometer/se/README.md @@ -34,7 +34,7 @@ The `GreetingService` class ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-integrations-micrometer-se.jar ``` @@ -43,23 +43,27 @@ java -jar target/helidon-examples-integrations-micrometer-se.jar These normal greeting app endpoints work just as in the original greeting app: -```bash +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} +``` +```shell curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"message":"Hello Joe!"} +``` +```shell 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!"} +#Output: {"message":"Hola Jose!"} ``` ## Using Micrometer Access the `/micrometer` endpoint which reports the newly-added timer and counter. -```bash +```shell curl http://localhost:8080/micrometer ``` @@ -68,8 +72,10 @@ the actual timer output includes a lengthy histogram (only part of which is show Your output might show the `personalizedGets` output before the `allGets` output, rather than after as shown here. -``` +```shell curl http://localhost:8080/micrometer +``` +```listing # HELP allGets_seconds_max # TYPE allGets_seconds_max gauge allGets_seconds_max 0.04341847 diff --git a/examples/integrations/micronaut/data/README.md b/examples/integrations/micronaut/data/README.md index b8443897e74..f08ff99967f 100644 --- a/examples/integrations/micronaut/data/README.md +++ b/examples/integrations/micronaut/data/README.md @@ -28,14 +28,14 @@ The following classes are pure Micronaut beans (and cannot have CDI injected int Start the application: -```bash +```shell mvn package java -jar target/helidon-examples-integrations-micronaut-data.jar ``` Access endpoints -```bash +```shell # Get all pets curl -i http://localhost:8080/pets # Get all owners diff --git a/examples/integrations/microstream/greetings-mp/README.md b/examples/integrations/microstream/greetings-mp/README.md index 850b81bffc9..b298250df2e 100644 --- a/examples/integrations/microstream/greetings-mp/README.md +++ b/examples/integrations/microstream/greetings-mp/README.md @@ -4,7 +4,7 @@ This example uses Microstream to persist the greetings supplied ## Build and run -``` +```shell mvn package java -jar target/helidon-examples-integrations-microstream-greetings-mp.jar ``` @@ -12,10 +12,17 @@ java -jar target/helidon-examples-integrations-microstream-greetings-mp.jar ## Endpoints Get default greeting message: +```shell curl -X GET http://localhost:7001/greet +``` -Get greeting message for Joe: +Get greeting message for Joe: + +```shell curl -X GET http://localhost:7001/greet/Joe +``` Add a greeting: -curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Howdy"}' http://localhost:7001/greet/greeting +```shell +curl -X PUT -H "Content-Type: application/json" -d '{"message" : "Howdy"}' http://localhost:7001/greet/greeting +``` \ No newline at end of file diff --git a/examples/integrations/microstream/greetings-se/README.md b/examples/integrations/microstream/greetings-se/README.md index c05d202abf8..358ca89397c 100644 --- a/examples/integrations/microstream/greetings-se/README.md +++ b/examples/integrations/microstream/greetings-se/README.md @@ -4,21 +4,29 @@ This example uses Microstream to persist a log entry for every greeting ## Build and run -``` +```shell mvn package java -jar target/helidon-examples-integrations-microstream-greetings-se.jar ``` ## Endpoints -Get default greeting message: +Get default greeting message: +```shell curl -X GET http://localhost:8080/greet +``` -Get greeting message for Joe: +Get greeting message for Joe: +```shell curl -X GET http://localhost:8080/greet/Joe +``` -Change greeting: +Change greeting: +```shell curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Howdy"}' http://localhost:8080/greet/greeting +``` -Get the logs: -curl -X GET http://localhost:8080/greet/logs \ No newline at end of file +Get the logs: +```shell +curl -X GET http://localhost:8080/greet/logs +``` \ No newline at end of file diff --git a/examples/integrations/neo4j/README.md b/examples/integrations/neo4j/README.md index d35611349cd..33060669bbb 100644 --- a/examples/integrations/neo4j/README.md +++ b/examples/integrations/neo4j/README.md @@ -4,21 +4,21 @@ Bring up a Neo4j instance via Docker -```bash +```shell docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret' neo4j:4.0 ``` Goto the Neo4j browser and play the first step of the movies graph: [`:play movies`](http://localhost:7474/browser/?cmd=play&arg=movies). Build and run with JDK20 -```bash +```shell mvn package -java -jar target/helidon-examples-integration-neo4j-nima.jar +java -jar target/helidon-examples-integration-neo4j.jar ``` Then access the rest API like this: -```` +````shell curl localhost:8080/api/movies ```` @@ -32,7 +32,7 @@ Enable them in the driver: metricsEnabled: true ``` -```` +```shell curl localhost:8080/observe/health curl localhost:8080/observe/metrics -```` +``` diff --git a/examples/integrations/oci/README.md b/examples/integrations/oci/README.md index ead822ac417..fe566dd162f 100644 --- a/examples/integrations/oci/README.md +++ b/examples/integrations/oci/README.md @@ -1 +1,5 @@ # OCI Java SDK Examples + +```shell +mvn package +``` diff --git a/examples/integrations/oci/atp-cdi/README.md b/examples/integrations/oci/atp-cdi/README.md index 33e8176703c..2af41874955 100644 --- a/examples/integrations/oci/atp-cdi/README.md +++ b/examples/integrations/oci/atp-cdi/README.md @@ -14,15 +14,15 @@ Before running the test, make sure to update required properties in `application Once you have updated required properties, you can run the example: -```shell script -mvn clean install +```shell +mvn package java -jar ./target/helidon-examples-integrations-oci-atp-cdi.jar ``` To verify that, you can retrieve wallet and do database operation: -```text -http://localhost:8080/atp/wallet +```shell +curl http://localhost:8080/atp/wallet ``` You should see `Hello world!!` \ No newline at end of file diff --git a/examples/integrations/oci/atp/README.md b/examples/integrations/oci/atp/README.md index c3e27d7c6bf..da82d2aa951 100644 --- a/examples/integrations/oci/atp/README.md +++ b/examples/integrations/oci/atp/README.md @@ -14,15 +14,15 @@ Before running the test, make sure to update required properties in `application Once you have updated required properties, you can run the example: -```shell script -mvn clean install +```shell +mvn package java -jar ./target/helidon-examples-integrations-oci-atp.jar ``` To verify that, you can retrieve wallet and do database operation: -```text -http://localhost:8080/atp/wallet +```shell +curl http://localhost:8080/atp/wallet ``` You should see `Hello world!!` diff --git a/examples/integrations/oci/metrics/README.md b/examples/integrations/oci/metrics/README.md new file mode 100644 index 00000000000..53a11340080 --- /dev/null +++ b/examples/integrations/oci/metrics/README.md @@ -0,0 +1,9 @@ +The metrics example. + +The example requires OCI config in some default place like ``.oci/config`` + +Build and run the example by +```shell +mvn package +java -jar ./target/helidon-examples-integrations-oci-metrics.jar +``` diff --git a/examples/integrations/oci/objectstorage-cdi/README.md b/examples/integrations/oci/objectstorage-cdi/README.md new file mode 100644 index 00000000000..aa08fbe0c61 --- /dev/null +++ b/examples/integrations/oci/objectstorage-cdi/README.md @@ -0,0 +1,11 @@ +The object storage (CDI) example. + +The example requires OCI config in some default place like ``.oci/config`` +Also properties from the ``src/main/resources/application.yaml`` shall be configured. +Like ``oci.objectstorage.bucketName`` + +Build and run the example by +```shell +mvn package +java -jar ./target/helidon-examples-integrations-oci-objectstorage-cdi.jar +``` diff --git a/examples/integrations/oci/objectstorage/README.md b/examples/integrations/oci/objectstorage/README.md new file mode 100644 index 00000000000..06c5c52ba24 --- /dev/null +++ b/examples/integrations/oci/objectstorage/README.md @@ -0,0 +1,9 @@ +The object storage example. + +The example requires OCI config in some default place like ``.oci/config`` + +Build and run the example by +```shell +mvn package +java -jar ./target/helidon-examples-integrations-oci-objectstorage.jar +``` diff --git a/examples/integrations/oci/vault-cdi/README.md b/examples/integrations/oci/vault-cdi/README.md new file mode 100644 index 00000000000..aba4193e192 --- /dev/null +++ b/examples/integrations/oci/vault-cdi/README.md @@ -0,0 +1,12 @@ +The vault (CDI) example. + +The example requires OCI config in some default place like ``.oci/config`` + +Also properties from the ``src/main/resources/application.yaml`` shall be configured. +Like ``oci.properties.compartment-ocid`` + +Build and run the example by +```shell +mvn package +java -jar ./target/helidon-examples-integrations-oci-vault-cdi.jar +``` \ No newline at end of file diff --git a/examples/integrations/oci/vault/README.md b/examples/integrations/oci/vault/README.md new file mode 100644 index 00000000000..42fa855114d --- /dev/null +++ b/examples/integrations/oci/vault/README.md @@ -0,0 +1,9 @@ +The vault example. + +The example requires OCI config in some default place like ``.oci/config`` + +Build and run the example by +```shell +mvn package +java -jar ./target/helidon-examples-integrations-oci-vault.jar +``` diff --git a/examples/integrations/vault/hcp-cdi/README.md b/examples/integrations/vault/hcp-cdi/README.md index cfc83d15172..764dabb49a4 100644 --- a/examples/integrations/vault/hcp-cdi/README.md +++ b/examples/integrations/vault/hcp-cdi/README.md @@ -20,7 +20,7 @@ mvn clean package 3. Start this application ```shell -java -jar ./target/ +java -jar ./target/helidon-examples-integrations-vault-hcp-cdi.jar ``` 4. Exercise the endpoints \ No newline at end of file diff --git a/examples/integrations/vault/hcp/README.md b/examples/integrations/vault/hcp/README.md index 7e30a173ac1..1bcbac31d2d 100644 --- a/examples/integrations/vault/hcp/README.md +++ b/examples/integrations/vault/hcp/README.md @@ -20,7 +20,7 @@ mvn clean package 3. Start this application ```shell -java -jar ./target/ +java -jar ./target/helidon-examples-integrations-vault-hcp.jar ``` 4. Exercise the endpoints \ No newline at end of file diff --git a/examples/jbatch/README.md b/examples/jbatch/README.md index 47cb6f0f6be..551fcdef8b3 100644 --- a/examples/jbatch/README.md +++ b/examples/jbatch/README.md @@ -4,13 +4,13 @@ Minimal Helidon MP + jBatch PoC. ## Build and run -```bash +```shell mvn package -java -jar target/helidon-jbatch-example.jar +java -jar target/helidon-examples-jbatch.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/batch ``` \ No newline at end of file diff --git a/examples/logging/jul/README.md b/examples/logging/jul/README.md index 17b02a3c834..44a10a6a2b9 100644 --- a/examples/logging/jul/README.md +++ b/examples/logging/jul/README.md @@ -9,12 +9,12 @@ The example can be built using GraalVM native image as well. # Running as jar Build this application: -```shell script +```shell mvn clean package ``` Run from command line: -```shell script +```shell java -jar target/helidon-examples-logging-jul.jar ``` @@ -33,12 +33,12 @@ or you can specify an environment variable `GRAALVM_HOME` that points to such an installation. Build this application: -```shell script +```shell mvn clean package -Pnative-image ``` Run from command line: -```shell script +```shell ./target/helidon-examples-logging-jul ``` diff --git a/examples/logging/log4j/README.md b/examples/logging/log4j/README.md index 3f49109bc7a..bf7f618921f 100644 --- a/examples/logging/log4j/README.md +++ b/examples/logging/log4j/README.md @@ -11,12 +11,12 @@ The example can be built using GraalVM native image as well. # Running as jar Build this application: -```shell script +```shell mvn clean package ``` Run from command line: -```shell script +```shell java -jar target/helidon-examples-logging-log4j.jar ``` @@ -35,12 +35,12 @@ or you can specify an environment variable `GRAALVM_HOME` that points to such an installation. Build this application: -```shell script +```shell mvn clean package -Pnative-image ``` Run from command line: -```shell script +```shell ./target/helidon-examples-logging-log4j ``` diff --git a/examples/logging/logback-aot/README.md b/examples/logging/logback-aot/README.md index 1bbecf1a93f..1ba544c0b3c 100644 --- a/examples/logging/logback-aot/README.md +++ b/examples/logging/logback-aot/README.md @@ -30,12 +30,12 @@ The output is also logged into `helidon.log`. # Running as jar Build this application: -```shell script +```shell mvn clean package ``` Run from command line: -```shell script +```shell java -jar target/helidon-examples-logging-slf4j-aot.jar ``` @@ -55,6 +55,6 @@ mvn clean package -Pnative-image ``` Run from command line: -```shell script -./target/helidon-examples-logging-sfl4j +```shell +./target/helidon-examples-logging-slf4j-aot ``` diff --git a/examples/logging/slf4j/README.md b/examples/logging/slf4j/README.md index daf8b065799..7ef0fcd5ca7 100644 --- a/examples/logging/slf4j/README.md +++ b/examples/logging/slf4j/README.md @@ -20,13 +20,13 @@ Expected output should be similar to the following (for both hotspot and native) # Running as jar Build this application: -```shell script +```shell mvn clean package ``` Run from command line: -```shell script -java -jar target/helidon-examples-logging-sfl4j.jar +```shell +java -jar target/helidon-examples-logging-slf4j.jar ``` # Running as native image @@ -35,11 +35,11 @@ or you can specify an environment variable `GRAALVM_HOME` that points to such an installation. Build this application: -```shell script +```shell mvn clean package -Pnative-image ``` Run from command line: -```shell script -./target/helidon-examples-logging-sfl4j -``` +```shell +./target/helidon-examples-logging-slf4j +``` \ No newline at end of file diff --git a/examples/media/multipart/README.md b/examples/media/multipart/README.md index 206a630c045..eb7ee218bf6 100644 --- a/examples/media/multipart/README.md +++ b/examples/media/multipart/README.md @@ -8,7 +8,7 @@ and downloading files. The unit test uses the `WebClient` API to test the endpoi ## Build -``` +```shell mvn package ``` @@ -16,7 +16,7 @@ mvn package First, start the server: -``` +```shell java -jar target/helidon-examples-media-multipart.jar ``` diff --git a/examples/messaging/README.md b/examples/messaging/README.md index 327077816b7..63201c10fb3 100644 --- a/examples/messaging/README.md +++ b/examples/messaging/README.md @@ -19,19 +19,19 @@ small, pocket size and pre-configured testing Kafka server Docker image is avail ### Test JMS server * Start ActiveMQ server locally: -```bash +```shell docker run --name='activemq' --rm -p 61616:61616 -p 8161:8161 rmohr/activemq ``` ### Test Oracle database * Start ActiveMQ server locally: -```bash +```shell cd ./docker/oracle-aq-18-xe ./buildAndRun.sh ``` For stopping Oracle database container use: -```bash +```shell cd ./docker/oracle-aq-18-xe ./stopAndClean.sh ``` diff --git a/examples/messaging/docker/oracle-aq-18-xe/buildAndRun.sh b/examples/messaging/docker/oracle-aq-18-xe/buildAndRun.sh old mode 100644 new mode 100755 index 685e82b8b1c..0d9d3334c70 --- a/examples/messaging/docker/oracle-aq-18-xe/buildAndRun.sh +++ b/examples/messaging/docker/oracle-aq-18-xe/buildAndRun.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020, 2021 Oracle and/or its affiliates. +# Copyright (c) 2020, 2024 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/examples/messaging/docker/oracle-aq-18-xe/stopAndClean.sh b/examples/messaging/docker/oracle-aq-18-xe/stopAndClean.sh old mode 100644 new mode 100755 index c39a8165053..4ba52254147 --- a/examples/messaging/docker/oracle-aq-18-xe/stopAndClean.sh +++ b/examples/messaging/docker/oracle-aq-18-xe/stopAndClean.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2020 Oracle and/or its affiliates. +# Copyright (c) 2020, 2024 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/examples/messaging/jms-websocket-mp/README.md b/examples/messaging/jms-websocket-mp/README.md index 9c7de44e4b4..bb3aeaa9e34 100644 --- a/examples/messaging/jms-websocket-mp/README.md +++ b/examples/messaging/jms-websocket-mp/README.md @@ -6,7 +6,11 @@ * [ActiveMQ server](../README.md) running on `localhost:61616` ## Build & Run -1. `mvn clean install` -2. `java -jar helidon-examples-jms-websocket-mp.jar` +```shell +#1. +mvn clean package +#2. + java -jar target/helidon-examples-jms-websocket-mp.jar +``` 3. Visit http://localhost:7001 diff --git a/examples/messaging/jms-websocket-se/README.md b/examples/messaging/jms-websocket-se/README.md index 5b8a223bac4..4d8eabba41d 100644 --- a/examples/messaging/jms-websocket-se/README.md +++ b/examples/messaging/jms-websocket-se/README.md @@ -6,7 +6,11 @@ * [ActiveMQ server](../README.md) running on `localhost:61616` ## Build & Run -1. `mvn clean install` -2. `java -jar helidon-examples-jms-websocket-se.jar` +```shell +#1. +mvn clean package +#2. +java -jar target/helidon-examples-jms-websocket-se.jar +``` 3. Visit http://localhost:7001 diff --git a/examples/messaging/jms-websocket-se/src/main/java/io/helidon/examples/messaging/se/Main.java b/examples/messaging/jms-websocket-se/src/main/java/io/helidon/examples/messaging/se/Main.java index e7cdfc3ef66..2d46ed70560 100644 --- a/examples/messaging/jms-websocket-se/src/main/java/io/helidon/examples/messaging/se/Main.java +++ b/examples/messaging/jms-websocket-se/src/main/java/io/helidon/examples/messaging/se/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023 Oracle and/or its affiliates. + * Copyright (c) 2020, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ static WebServer startServer() throws IOException { .addRouting(WsRouting.builder() .endpoint("/ws/messages", new WebSocketEndpoint())) .config(config.get("server")) - .build(); + .build().start(); System.out.println("WEB server is up! http://localhost:" + server.port()); Runtime.getRuntime().addShutdownHook(new Thread(sendingService::shutdown)); diff --git a/examples/messaging/kafka-websocket-mp/README.md b/examples/messaging/kafka-websocket-mp/README.md index 3a815337b34..75269ca5ca0 100644 --- a/examples/messaging/kafka-websocket-mp/README.md +++ b/examples/messaging/kafka-websocket-mp/README.md @@ -6,6 +6,10 @@ * [Kafka bootstrap server](../README.md) running on `localhost:9092` ## Build & Run -1. `mvn clean install` -2. `java -jar mp-example.jar` +```shell +#1. +mvn clean package +#2. +java -jar target/kafka-websocket-mp.jar +``` 3. Visit http://localhost:7001 \ No newline at end of file diff --git a/examples/messaging/kafka-websocket-se/README.md b/examples/messaging/kafka-websocket-se/README.md index 505e25afd3b..c3e397add51 100644 --- a/examples/messaging/kafka-websocket-se/README.md +++ b/examples/messaging/kafka-websocket-se/README.md @@ -6,7 +6,11 @@ * [Kafka bootstrap server](../README.md) running on `localhost:9092` ## Build & Run -1. `mvn clean install` -2. `java -jar se-example.jar` +```shell +#1. +mvn clean package +#2. +java -jar target/kafka-websocket-se.jar +``` 3. Visit http://localhost:7001 diff --git a/examples/messaging/oracle-aq-websocket-mp/README.md b/examples/messaging/oracle-aq-websocket-mp/README.md index 1d66e681e3d..af31df6f51e 100644 --- a/examples/messaging/oracle-aq-websocket-mp/README.md +++ b/examples/messaging/oracle-aq-websocket-mp/README.md @@ -6,7 +6,11 @@ * [Oracle database](../README.md) running on `localhost:1521` ## Build & Run -1. `mvn clean install` -2. `java -jar aq-websocket-mp.jar` +```shell +#1. + mvn clean package +#2. + java -jar target/aq-websocket-mp.jar +``` 3. Visit http://localhost:7001 diff --git a/examples/messaging/weblogic-jms-mp/README.md b/examples/messaging/weblogic-jms-mp/README.md index 21023110bf4..610a417f12d 100644 --- a/examples/messaging/weblogic-jms-mp/README.md +++ b/examples/messaging/weblogic-jms-mp/README.md @@ -1,7 +1,7 @@ # Helidon Messaging with Oracle Weblogic Example ## Prerequisites -* JDK 17+ +* JDK 21+ * Maven * Docker * Account at https://container-registry.oracle.com/ with accepted Oracle Standard Terms and Restrictions for Weblogic. @@ -18,7 +18,11 @@ ## Build & Run To run Helidon with thin client, flag `--add-opens=java.base/java.io=ALL-UNNAMED` is needed to open java.base module to thin client internals. -1. `mvn clean package` -2. `java --add-opens=java.base/java.io=ALL-UNNAMED -jar ./target/weblogic-jms-mp.jar` +```shell +#1. + mvn clean package +#2. + java --add-opens=java.base/java.io=ALL-UNNAMED -jar ./target/weblogic-jms-mp.jar +``` 3. Visit http://localhost:8080 and try to send and receive messages over Weblogic JMS queue. diff --git a/examples/metrics/exemplar/README.md b/examples/metrics/exemplar/README.md index 09125f0ffbd..fd9bcf65ed1 100644 --- a/examples/metrics/exemplar/README.md +++ b/examples/metrics/exemplar/README.md @@ -9,33 +9,33 @@ when it cannot contact the Zipkin server to report the tracing spans. Even so, t will contain valid exemplars. With Docker: -```bash +```shell docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin ``` ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-metrics-exemplar.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#output: {"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!"} +#output: {"message":"Hola Jose!"} curl -X GET http://localhost:8080/greet -{"message":"Hola World!"} +#output: {"message":"Hola World!"} ``` ## Retrieve application metrics @@ -43,7 +43,7 @@ curl -X GET http://localhost:8080/greet ``` # Prometheus format with exemplars -curl -s -X GET http://localhost:8080/metrics/application +curl -s -X GET http://localhost:8080/observe/metrics/application # TYPE application_counterForPersonalizedGreetings_total counter # HELP application_counterForPersonalizedGreetings_total application_counterForPersonalizedGreetings_total 2 # {trace_id="78e61eed351f4c9d"} 1 1617812495.016000 @@ -53,7 +53,7 @@ application_timerForGets_mean_seconds 0.005772598385062112 # {trace_id="b22f13c3 # TYPE application_timerForGets_max_seconds gauge application_timerForGets_max_seconds 0.028018165 # {trace_id="a1b127002725143c"} 0.028018165 1617812467.524000 ``` -The examplars contain `trace_id` values tying them to specific samples. +The exemplars contain `trace_id` values tying them to specific samples. Note that the exemplar for the counter refers to the most recent update to the counter. For the timer, the value for the `max` is exactly the same as the value for its exemplar, diff --git a/examples/metrics/filtering/mp/README.md b/examples/metrics/filtering/mp/README.md new file mode 100644 index 00000000000..fb4fa520d85 --- /dev/null +++ b/examples/metrics/filtering/mp/README.md @@ -0,0 +1,47 @@ +# Helidon Metrics Filtering MP Example + +This project implements a simple Hello World REST service using Helidon SE and demonstrates the +optional metrics exemplar support. + +## Build and run + +```shell +mvn package +java -jar target/helidon-examples-metrics-filtering-mp.jar +``` + +## Exercise the application + +```shell +curl -X GET http://localhost:8080/greet +#Output: {"message":"Hello World!"} + +curl -X GET http://localhost:8080/greet/Joe +#Output: {"message":"Hello Joe!"} + +curl -X PUT -H "Content-Type: application/json" -d '{"message" : "Hola"}' http://localhost:8080/greet/greeting + +curl -X GET http://localhost:8080/greet/Jose +#Output: {"message":"Hola Jose!"} + +curl -X GET http://localhost:8080/greet +#Output: {"message":"Hola World!"} +``` + +## Retrieve application metrics + +```shell +# Prometheus format with exemplars + +curl -s -X GET http://localhost:8080/metrics/application +``` +``` +# TYPE application_counterForPersonalizedGreetings_total counter +# HELP application_counterForPersonalizedGreetings_total +application_counterForPersonalizedGreetings_total 2 # {trace_id="78e61eed351f4c9d"} 1 1617812495.016000 +. . . +# TYPE application_timerForGets_mean_seconds gauge +application_timerForGets_mean_seconds 0.005772598385062112 # {trace_id="b22f13c37ba8b879"} 0.001563945 1617812578.687000 +# TYPE application_timerForGets_max_seconds gauge +application_timerForGets_max_seconds 0.028018165 # {trace_id="a1b127002725143c"} 0.028018165 1617812467.524000 +``` diff --git a/examples/metrics/filtering/se/README.md b/examples/metrics/filtering/se/README.md new file mode 100644 index 00000000000..bbbd3ebab5d --- /dev/null +++ b/examples/metrics/filtering/se/README.md @@ -0,0 +1,47 @@ +# Helidon Filtering Metrics SE Example + +This project implements a simple Hello World REST service using Helidon SE and demonstrates the +optional metrics exemplar support. + +## Build and run + +```shell +mvn package +java -jar target/helidon-examples-metrics-se.jar +``` + +## Exercise the application + +```shell +curl -X GET http://localhost:8080/greet +#Output: {"message":"Hello World!"} + +curl -X GET http://localhost:8080/greet/Joe +#Output: {"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 +#Output: {"message":"Hola Jose!"} + +curl -X GET http://localhost:8080/greet +#Output: {"message":"Hola World!"} +``` + +## Retrieve application metrics + +```shell +# Prometheus format with exemplars + +curl -s -X GET http://localhost:8080/observe/metrics/application +``` +``` +# TYPE application_counterForPersonalizedGreetings_total counter +# HELP application_counterForPersonalizedGreetings_total +application_counterForPersonalizedGreetings_total 2 # {trace_id="78e61eed351f4c9d"} 1 1617812495.016000 +. . . +# TYPE application_timerForGets_mean_seconds gauge +application_timerForGets_mean_seconds 0.005772598385062112 # {trace_id="b22f13c37ba8b879"} 0.001563945 1617812578.687000 +# TYPE application_timerForGets_max_seconds gauge +application_timerForGets_max_seconds 0.028018165 # {trace_id="a1b127002725143c"} 0.028018165 1617812467.524000 +``` \ No newline at end of file diff --git a/examples/metrics/http-status-count-se/README.md b/examples/metrics/http-status-count-se/README.md index 13214595e66..e660e3832e3 100644 --- a/examples/metrics/http-status-count-se/README.md +++ b/examples/metrics/http-status-count-se/README.md @@ -23,32 +23,32 @@ Use this example for inspiration in writing your own service or just use the `Ht ## Build and run -```bash +```shell mvn package java -jar target/http-status-count-se.jar ``` ## Exercise the application -```bash +```shell curl -X GET http://localhost:8080/simple-greet ``` ```listing {"message":"Hello World!"} ``` -```bash +```shell curl -X GET http://localhost:8080/greet ``` ```listing {"message":"Hello World!"} ``` -```bash +```shell curl -X GET http://localhost:8080/greet/Joe ``` ```listing {"message":"Hello Joe!"} ``` -```bash +```shell curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose @@ -58,9 +58,9 @@ curl -X GET http://localhost:8080/greet/Jose ``` ## Try metrics -```bash +```shell # Prometheus Format -curl -s -X GET http://localhost:8080/metrics/application +curl -s -X GET http://localhost:8080/observe/metrics/application ``` ```listing @@ -76,8 +76,8 @@ application_httpStatus_total{range="5xx"} 0 ``` # JSON Format -```bash -curl -H "Accept: application/json" -X GET http://localhost:8080/metrics +```shell +curl -H "Accept: application/json" -X GET http://localhost:8080/observe/metrics ``` ```json { @@ -92,7 +92,7 @@ curl -H "Accept: application/json" -X GET http://localhost:8080/metrics ## Try health -```bash +```shell curl -s -X GET http://localhost:8080/health ``` ```listing diff --git a/examples/metrics/kpi/README.md b/examples/metrics/kpi/README.md index c0fe038d54b..6584578fb76 100644 --- a/examples/metrics/kpi/README.md +++ b/examples/metrics/kpi/README.md @@ -11,34 +11,34 @@ You would typically write any given application to use only one of the approache ## Build and run -```bash +```shell mvn package ``` To use programmatic set-up: -```bash +```shell java -jar target/helidon-examples-metrics-kpi.jar ``` To use configuration: -```bash +```shell java -DuseConfig=true -jar target/helidon-examples-metrics-kpi.jar ```` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"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!"} +#Output: {"message":"Hola Jose!"} curl -X GET http://localhost:8080/greet -{"message":"Hola World!"} +#Output: {"message":"Hola World!"} ``` ## Retrieve vendor metrics with key performance indicators @@ -74,8 +74,10 @@ not reflect the fact that Helidon would subsequently conclude that _that_ reques long-running. ## Prometheus format +```shell +curl -s -X GET http://localhost:8080/observe/metrics/vendor +``` ``` -curl -s -X GET http://localhost:8080/metrics/vendor ... # TYPE vendor_requests_inFlight_current concurrent gauge # HELP vendor_requests_inFlight_current Measures the number of currently in-flight requests @@ -100,8 +102,10 @@ vendor_requests_load_fifteen_min_rate_per_second 0.005104944851522425 ## JSON output -```bash -curl -s -X GET -H "Accept: application/json" http://localhost:8080/metrics/vendor +```shell +curl -s -X GET -H "Accept: application/json" http://localhost:8080/observe/metrics/vendor +``` +``` { ... "requests.inFlight": { diff --git a/examples/microprofile/bean-validation/README.md b/examples/microprofile/bean-validation/README.md index 3d6ec318871..0d6a80a35cb 100644 --- a/examples/microprofile/bean-validation/README.md +++ b/examples/microprofile/bean-validation/README.md @@ -15,20 +15,21 @@ To be able to use bean validation add the following dependency: ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-bean-validation.jar ``` ## Exercise the application -``` -curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} - -curl -X GET -I http://localhost:8080/greet/null +```shell +curl -X GET http://localhost:8080/valid/test@test.com +#Output: {"Valid test@test.com!"} +curl -X GET -I http://localhost:8080/valid/null +``` +``` HTTP/1.1 400 Bad Request Content-Type: application/json transfer-encoding: chunked diff --git a/examples/microprofile/cors/README.md b/examples/microprofile/cors/README.md index 5f665c8c131..575d01933b7 100644 --- a/examples/microprofile/cors/README.md +++ b/examples/microprofile/cors/README.md @@ -9,7 +9,7 @@ uncomment that line and then package and run the application. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-cors.jar ``` @@ -18,17 +18,17 @@ java -jar target/helidon-examples-microprofile-cors.jar These normal greeting app endpoints work just as in the original greeting app: -```bash +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"message":"Hello Joe!"} -curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting +curl -X PUT -H "Content-Type: application/json" -d '{"message" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose -{"message":"Hola Jose!"} +#Output: {"message":"Hola Jose!"} ``` ## Using CORS @@ -40,9 +40,11 @@ The following requests illustrate the CORS protocol with the example app. By setting `Origin` and `Host` headers that do not indicate the same system we trigger CORS processing in the server: -```bash +```shell # Follow the CORS protocol for GET curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet +``` +``` HTTP/1.1 200 OK Access-Control-Allow-Origin: * @@ -58,9 +60,9 @@ Note the new headers `Access-Control-Allow-Origin` and `Vary` in the response. The same happens for a `GET` requesting a personalized greeting (by passing the name of the person to be greeted): -```bash +```shell curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet/Joe -{"greeting":"Hola Joe!"} +#Output: {"greeting":"Hola Joe!"} ``` Take a look at `GreetResource` and in particular the methods named `optionsForXXX` near the end of the class. There is one for each different subpath that the resource's endpoints handle: no subpath, `/{name}`, and `/greeting`. The @@ -83,13 +85,14 @@ requests as "non-simple" ones. This command sends a pre-flight `OPTIONS` request to see if the server will accept a subsequent `PUT` request from the specified origin to change the greeting: -```bash +```shell curl -i -X OPTIONS \ -H "Access-Control-Request-Method: PUT" \ -H "Origin: http://foo.com" \ -H "Host: here.com" \ http://localhost:8080/greet/greeting - +``` +``` HTTP/1.1 200 OK Access-Control-Allow-Methods: PUT Access-Control-Allow-Origin: http://foo.com @@ -100,16 +103,17 @@ connection: keep-alive The successful status and the returned `Access-Control-Allow-xxx` headers indicate that the server accepted the pre-flight request. That means it is OK for us to send `PUT` request to perform the actual change of greeting. (See below for how the server rejects a pre-flight request.) -```bash +```shell curl -i -X PUT \ -H "Origin: http://foo.com" \ -H "Host: here.com" \ -H "Access-Control-Allow-Methods: PUT" \ -H "Access-Control-Allow-Origin: http://foo.com" \ -H "Content-Type: application/json" \ - -d "{ \"greeting\" : \"Cheers\" }" \ + -d "{ \"message\" : \"Cheers\" }" \ http://localhost:8080/greet/greeting - +``` +``` HTTP/1.1 204 No Content Access-Control-Allow-Origin: http://foo.com Date: Thu, 30 Apr 2020 17:32:55 -0500 @@ -117,9 +121,9 @@ Vary: Origin connection: keep-alive ``` And we run one more `GET` to observe the change in the greeting: -```bash +```shell curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet/Joe -{"greeting":"Cheers Joe!"} +#Output: {"greeting":"Cheers Joe!"} ``` Note that the tests in the example `TestCORS` class follow these same steps. diff --git a/examples/microprofile/graphql/README.md b/examples/microprofile/graphql/README.md index 00ed22f33e0..aed1a6d8437 100644 --- a/examples/microprofile/graphql/README.md +++ b/examples/microprofile/graphql/README.md @@ -10,13 +10,13 @@ for an introduction to using GraphQL in Helidon MP. 1. Build -```bash +```shell mvn clean install ``` 2. Run the example -```bash +```shell java -jar target/helidon-examples-microprofile-graphql.jar ``` @@ -26,7 +26,7 @@ Access the `/graphql` endpoint via `http://127.0.0.1:7001/graphql`: 1. Display the generated GraphQL Schema - ```bash + ```shell curl http://127.0.0.1:7001/graphql/schema.graphql ``` @@ -64,7 +64,7 @@ Access the `/graphql` endpoint via `http://127.0.0.1:7001/graphql`: 1. Create a Task - ```bash + ```shell curl -X POST http://127.0.0.1:7001/graphql -d '{"query":"mutation createTask { createTask(description: \"Task Description 1\") { id description createdAt completed }}"}' ``` @@ -84,9 +84,10 @@ In the case below we have also appended `/application` to the URL to just retrie > Note: `jq` has been used to format the JSON output. This can be downloaded from https://stedolan.github.io/jq/download/ or you can > format the output with an alternate utility. -```bash -$ curl -H 'Accept: application/json' http://127.0.0.1:7001/metrics/application | jq - +```shell +curl -H 'Accept: application/json' http://127.0.0.1:7001/metrics/application | jq +``` +``` { "io.helidon.examples.graphql.basics.TaskApi.TaskApi": { "count": 1, diff --git a/examples/microprofile/hello-world-explicit/README.md b/examples/microprofile/hello-world-explicit/README.md index 837350fe6b2..e93f7a68911 100644 --- a/examples/microprofile/hello-world-explicit/README.md +++ b/examples/microprofile/hello-world-explicit/README.md @@ -4,14 +4,14 @@ This examples shows a simple application written using Helidon MP. It is explicit because in this example you write the `main` class and explicitly start the microprofile server. -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-hello-world-explicit.jar ``` Then try the endpoints: -``` +```shell curl -X GET http://localhost:7001/helloworld curl -X GET http://localhost:7001/helloworld/earth ``` diff --git a/examples/microprofile/hello-world-explicit/src/main/java/io/helidon/microprofile/example/helloworld/explicit/Main.java b/examples/microprofile/hello-world-explicit/src/main/java/io/helidon/microprofile/example/helloworld/explicit/Main.java index fe420cf14a7..c85566f5eac 100644 --- a/examples/microprofile/hello-world-explicit/src/main/java/io/helidon/microprofile/example/helloworld/explicit/Main.java +++ b/examples/microprofile/hello-world-explicit/src/main/java/io/helidon/microprofile/example/helloworld/explicit/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020 Oracle and/or its affiliates. + * Copyright (c) 2018, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,8 +33,8 @@ private Main() { public static void main(String[] args) { Server server = Server.builder() .host("localhost") - // use a random free port - .port(0) + // use port 7001 as per README.md + .port(7001) .build(); server.start(); diff --git a/examples/microprofile/hello-world-implicit/README.md b/examples/microprofile/hello-world-implicit/README.md index 393607f09da..e8d812a973f 100644 --- a/examples/microprofile/hello-world-implicit/README.md +++ b/examples/microprofile/hello-world-implicit/README.md @@ -6,14 +6,14 @@ It is implicit because in this example you don't write the ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-hello-world-implicit.jar ``` Then try the endpoints: -``` +```shell curl -X GET http://localhost:7001/helloworld curl -X GET http://localhost:7001/helloworld/earth curl -X GET http://localhost:7001/another diff --git a/examples/microprofile/http-status-count-mp/README.md b/examples/microprofile/http-status-count-mp/README.md index 6bd420154be..e3329320be4 100644 --- a/examples/microprofile/http-status-count-mp/README.md +++ b/examples/microprofile/http-status-count-mp/README.md @@ -9,32 +9,32 @@ Use this example for inspiration in writing your own filter or just use the filt ## Build and run -```bash +```shell mvn package java -jar target/http-status-count-mp.jar ``` ## Exercise the application -```bash +```shell curl -X GET http://localhost:8080/simple-greet ``` ```listing {"message":"Hello World!"} ``` -```bash +```shell curl -X GET http://localhost:8080/greet ``` ```listing {"message":"Hello World!"} ``` -```bash +```shell curl -X GET http://localhost:8080/greet/Joe ``` ```listing {"message":"Hello Joe!"} ``` -```bash +```shell curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose @@ -44,7 +44,7 @@ curl -X GET http://localhost:8080/greet/Jose ``` ## Try metrics -```bash +```shell # Prometheus Format curl -s -X GET http://localhost:8080/metrics/application ``` @@ -62,7 +62,7 @@ application_httpStatus_total{range="5xx"} 0 ``` # JSON Format -```bash +```shell curl -H "Accept: application/json" -X GET http://localhost:8080/metrics ``` ```json diff --git a/examples/microprofile/idcs/README.md b/examples/microprofile/idcs/README.md index 0105956f52c..2ac3ecbacc7 100644 --- a/examples/microprofile/idcs/README.md +++ b/examples/microprofile/idcs/README.md @@ -39,7 +39,7 @@ Edit application.yaml based on your IDCS Configuration ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-security-idcs.jar ``` diff --git a/examples/microprofile/lra/README.md b/examples/microprofile/lra/README.md index dbcf3e61b62..41e38cb4308 100644 --- a/examples/microprofile/lra/README.md +++ b/examples/microprofile/lra/README.md @@ -2,8 +2,9 @@ ## Build and run -```bash -mvn install && java -jar ./target/helidon-examples-microprofile-lra.jar +```shell +mvn package +java -jar ./target/helidon-examples-microprofile-lra.jar ``` ### Coordinator @@ -22,7 +23,7 @@ docker run --rm --name lra-coordinator --network="host" helidon/lra-coordinator ### Test LRA resource Then call for completed transaction: -```bash +```shell curl -X PUT -d 'lra rocks' http://localhost:7001/example/start-example ``` And observe processing success in the output followed by complete called by LRA coordinator: @@ -32,7 +33,7 @@ LRA id: f120a842-88da-429b-82d9-7274ee9ce8f6 completed 🎉 ``` For compensated transaction: -```bash +```shell curl -X PUT -d BOOM http://localhost:7001/example/start-example ``` Observe exception in the output followed by compensation called by LRA coordinator: @@ -44,6 +45,6 @@ LRA id: 3629421b-b2a4-4fc4-a2f0-941cbf3fa8ad compensated 🚒 ``` Or compensated transaction timeout: -```bash +```shell curl -X PUT -d TIMEOUT http://localhost:7001/example/start-example ``` \ No newline at end of file diff --git a/examples/microprofile/messaging-sse/README.md b/examples/microprofile/messaging-sse/README.md index 4c785716ddc..11f1719b286 100644 --- a/examples/microprofile/messaging-sse/README.md +++ b/examples/microprofile/messaging-sse/README.md @@ -7,7 +7,7 @@ ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-messaging-sse.jar ``` diff --git a/examples/microprofile/multipart/README.md b/examples/microprofile/multipart/README.md index 205b69b67ea..58aea2ba671 100644 --- a/examples/microprofile/multipart/README.md +++ b/examples/microprofile/multipart/README.md @@ -7,7 +7,7 @@ This project implements a simple file service web application that supports uplo ## Build -``` +```shell mvn package ``` @@ -15,7 +15,7 @@ mvn package First, start the server: -``` +```shell java -jar target/helidon-examples-microprofile-multipart.jar ``` diff --git a/examples/microprofile/multiport/README.md b/examples/microprofile/multiport/README.md index 47104b8c61e..4ec6b8ae9eb 100644 --- a/examples/microprofile/multiport/README.md +++ b/examples/microprofile/multiport/README.md @@ -21,14 +21,14 @@ using @RoutingName. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-multiport.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/hello curl -X GET http://localhost:8081/private/hello diff --git a/examples/microprofile/oci-tls-certificates/README.md b/examples/microprofile/oci-tls-certificates/README.md index 9128f73afed..856840195f7 100644 --- a/examples/microprofile/oci-tls-certificates/README.md +++ b/examples/microprofile/oci-tls-certificates/README.md @@ -79,12 +79,14 @@ Optional: ### Prepare keys and certificates Make sure you are in the directory [./etc/unsupported-cert-tools/](etc/unsupported-cert-tools/). ```shell +cd etc/unsupported-cert-tools/ bash create-keys.sh ``` ## Rotating mTLS certificates Make sure you are in the directory [./etc/unsupported-cert-tools/](etc/unsupported-cert-tools/). ```shell +cd etc/unsupported-cert-tools bash rotate-keys.sh ``` ⚠️ Keep in mind that rotation creates new [versions](https://docs.oracle.com/en-us/iaas/Content/certificates/rotation-states.htm), OCIDs of the keys and certificates stays the same, and you don't need to change your configuration. diff --git a/examples/microprofile/oidc/README.md b/examples/microprofile/oidc/README.md index 80f82b7f561..81ff0e7a78d 100644 --- a/examples/microprofile/oidc/README.md +++ b/examples/microprofile/oidc/README.md @@ -21,7 +21,7 @@ in `application.yaml`. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-security-oidc-login.jar ``` diff --git a/examples/microprofile/openapi/README.md b/examples/microprofile/openapi/README.md index 1fdefe9737a..3141be919f2 100644 --- a/examples/microprofile/openapi/README.md +++ b/examples/microprofile/openapi/README.md @@ -5,27 +5,27 @@ Helidon MP QuickStart, enhanced with OpenAPI support. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-openapi.jar ``` Try the endpoints: -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"message":"Hello Joe!"} -curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting +curl -X PUT -H "Content-Type: application/json" -d '{"message" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose -{"message":"Hola Jose!"} +#Output: {"message":"Hola Jose!"} curl -X GET http://localhost:8080/openapi -[lengthy OpenAPI document] +#Output: [lengthy OpenAPI document] ``` The output describes not only then endpoints from `GreetResource` but also one contributed by the `SimpleAPIModelReader`. diff --git a/examples/microprofile/security/README.md b/examples/microprofile/security/README.md index 5ca389935a8..7636f44b946 100644 --- a/examples/microprofile/security/README.md +++ b/examples/microprofile/security/README.md @@ -9,7 +9,7 @@ levels of security. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-mp1_1-security.jar ``` diff --git a/examples/microprofile/static-content/README.md b/examples/microprofile/static-content/README.md index 0209a9686aa..083ac410377 100644 --- a/examples/microprofile/static-content/README.md +++ b/examples/microprofile/static-content/README.md @@ -7,7 +7,7 @@ The configuration for the static content is in the ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-mp1_1-static-content.jar ``` diff --git a/examples/microprofile/telemetry/README.md b/examples/microprofile/telemetry/README.md index a93604850f7..621c9fa9e55 100644 --- a/examples/microprofile/telemetry/README.md +++ b/examples/microprofile/telemetry/README.md @@ -4,13 +4,13 @@ This example implements demonstrates usage of MP Telemetry Tracing. ## Build and run -```bash +```shell mvn package java -jar greeting/target/helidon-examples-microprofile-telemetry-greeting.jar ``` Run Jaeger tracer. If you prefer to use Docker, run in terminal: -```bash +```shell docker run -d --name jaeger \ -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \ -e COLLECTOR_OTLP_ENABLED=true \ @@ -29,33 +29,37 @@ docker run -d --name jaeger \ If you have Jaeger all-in-one installed, use this command: -```bash +```shell jaeger-all-in-one --collector.zipkin.host-port=9411 --collector.otlp.enabled=true ``` Run the Secondary service: -```bash +```shell mvn package java -jar secondary/target/helidon-examples-microprofile-telemetry-secondary.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/greet -"Hello World!" +#Output: "Hello World!" curl -X GET http://localhost:8080/greet/span -{"Span":"PropagatedSpan{ImmutableSpanContext{traceId=00000000000000000000000000000000, spanId=0000000000000000, traceFlags=00, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=false}}"} +#Output: {"Span":"PropagatedSpan{ImmutableSpanContext{traceId=00000000000000000000000000000000, spanId=0000000000000000, traceFlags=00, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=false}}"} curl -X GET http://localhost:8080/greet/custom +``` +``` +#Output: { "Custom Span": "SdkSpan{traceId=bea7da56d1fe82400af8ec0a8adb370d, spanId=57647ead5dc32ae7, parentSpanContext=ImmutableSpanContext{traceId=bea7da56d1fe82400af8ec0a8adb370d, spanId=0ca670f1e3330ea5, traceFlags=01, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=true}, name=custom, kind=INTERNAL, attributes=AttributesMap{data={attribute=value}, capacity=128, totalAddedValues=1}, status=ImmutableStatusData{statusCode=UNSET, description=}, totalRecordedEvents=0, totalRecordedLinks=0, startEpochNanos=1683724682576003542, endEpochNanos=1683724682576006000}" } - +``` +```shell curl -X GET http://localhost:8080/greet/outbound -Secondary +#Output: Secondary ``` diff --git a/examples/microprofile/tls/README.md b/examples/microprofile/tls/README.md index 4ff2af2ce27..31bceaacb7d 100644 --- a/examples/microprofile/tls/README.md +++ b/examples/microprofile/tls/README.md @@ -6,11 +6,11 @@ Note: This example uses self-signed server certificate! ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-tls.jar ``` ## Exercise the application -```bash +```shell curl -k -X GET https://localhost:8080 ``` diff --git a/examples/microprofile/websocket/README.md b/examples/microprofile/websocket/README.md index 64ae0882325..60300ddd9c5 100644 --- a/examples/microprofile/websocket/README.md +++ b/examples/microprofile/websocket/README.md @@ -5,11 +5,8 @@ that combines REST resources and WebSocket endpoints. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-microprofile-websocket.jar ``` - -``` -http://localhost:7001/web/index.html -``` +[Open In browser](http://localhost:7001/web/index.html) diff --git a/examples/openapi/README.md b/examples/openapi/README.md index baf86178283..370bf8f1f91 100644 --- a/examples/openapi/README.md +++ b/examples/openapi/README.md @@ -9,27 +9,27 @@ with the application. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-openapi.jar ``` Try the endpoints: -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"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!"} +#Output: {"message":"Hola Jose!"} curl -X GET http://localhost:8080/openapi -[lengthy OpenAPI document] +#Output: [lengthy OpenAPI document] ``` The output describes not only then endpoints in `GreetService` as described in diff --git a/examples/quickstarts/helidon-quickstart-mp/README.md b/examples/quickstarts/helidon-quickstart-mp/README.md index cc9259deb48..c5a0e678264 100644 --- a/examples/quickstarts/helidon-quickstart-mp/README.md +++ b/examples/quickstarts/helidon-quickstart-mp/README.md @@ -4,54 +4,51 @@ This example implements a simple Hello World REST service using MicroProfile. ## Build and run -```bash +```shell mvn package java -jar target/helidon-quickstart-mp.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"message":"Hello Joe!"} -curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting +curl -X PUT -H "Content-Type: application/json" -d '{"message" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose -{"message":"Hola Jose!"} +#Output: {"message":"Hola Jose!"} ``` ## Try health and metrics -``` +```shell curl -s -X GET http://localhost:8080/health -{"outcome":"UP",... -. . . +#Output: {"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":... -. . . - +#Output: {"base":... ``` ## Build the Docker Image -``` +```shell docker build -t helidon-quickstart-mp . ``` ## Start the application with Docker -``` +```shell docker run --rm -p 8080:8080 helidon-quickstart-mp:latest ``` @@ -59,7 +56,7 @@ Exercise the application as described above ## Deploy the application to Kubernetes -``` +```shell kubectl cluster-info # Verify which cluster kubectl get pods # Verify connectivity to cluster kubectl create -f app.yaml # Deploy application @@ -81,7 +78,7 @@ You can build a native executable in 2 different ways: Download Graal VM at https://www.graalvm.org/downloads. We recommend version `23.1.0` or later. -``` +```shell # Setup the environment export GRAALVM_HOME=/path # build the native executable @@ -96,7 +93,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-quickstart-mp ``` @@ -104,13 +101,13 @@ Start the application: Build the "native" Docker Image -``` +```shell docker build -t helidon-quickstart-mp-native -f Dockerfile.native . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-quickstart-mp-native:latest ``` @@ -130,7 +127,7 @@ You can build a custom JRI in two different ways: ### Local build -``` +```shell # build the JRI mvn package -Pjlink-image ``` @@ -140,7 +137,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-quickstart-mp-jri/bin/start ``` @@ -148,18 +145,18 @@ Start the application: Build the JRI as a Docker Image -``` +```shell docker build -t helidon-quickstart-mp-jri -f Dockerfile.jlink . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-quickstart-mp-jri:latest ``` See the start script help: -``` +```shell docker run --rm helidon-quickstart-mp-jri:latest --help ``` diff --git a/examples/quickstarts/helidon-quickstart-se/README.md b/examples/quickstarts/helidon-quickstart-se/README.md index ef45a423e8f..bbb38bcc9ba 100644 --- a/examples/quickstarts/helidon-quickstart-se/README.md +++ b/examples/quickstarts/helidon-quickstart-se/README.md @@ -4,55 +4,51 @@ This project implements a simple Hello World REST service using Helidon SE. ## Build and run -With20+ -```bash +```shell mvn package java -jar target/helidon-quickstart-se.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"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!"} +#Output: {"message":"Hola Jose!"} ``` ## Try health and metrics -``` -curl -s -X GET http://localhost:8080/health -{"outcome":"UP",... -. . . +```shell +curl -s -X GET http://localhost:8080/observe/health +#Output: {"outcome":"UP",... # Prometheus Format -curl -s -X GET http://localhost:8080/metrics +curl -s -X GET http://localhost:8080/observe/metrics # TYPE base:gc_g1_young_generation_count gauge -. . . # JSON Format -curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics -{"base":... -. . . +curl -H 'Accept: application/json' -X GET http://localhost:8080/observe/metrics +#Output: {"base":... ``` ## Build the Docker Image -``` +```shell docker build -t helidon-quickstart-se . ``` ## Start the application with Docker -``` +```shell docker run --rm -p 8080:8080 helidon-quickstart-se:latest ``` @@ -60,7 +56,7 @@ Exercise the application as described above ## Deploy the application to Kubernetes -``` +```shell kubectl cluster-info # Verify which cluster kubectl get pods # Verify connectivity to cluster kubectl create -f app.yaml # Deply application @@ -82,7 +78,7 @@ You can build a native executable in 2 different ways: Download Graal VM at https://www.graalvm.org/downloads. We recommend version `23.1.0` or later. -``` +```shell # Setup the environment export GRAALVM_HOME=/path # build the native executable @@ -97,7 +93,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-quickstart-se ``` @@ -105,13 +101,13 @@ Start the application: Build the "native" Docker Image -``` +```shell docker build -t helidon-quickstart-se-native -f Dockerfile.native . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-quickstart-se-native:latest ``` @@ -130,7 +126,7 @@ You can build a custom JRI in two different ways: ### Local build -``` +```shell # build the JRI mvn package -Pjlink-image ``` @@ -140,7 +136,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-quickstart-se-jri/bin/start ``` @@ -148,18 +144,18 @@ Start the application: Build the JRI as a Docker Image -``` +```shell docker build -t helidon-quickstart-se-jri -f Dockerfile.jlink . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-quickstart-se-jri:latest ``` See the start script help: -``` +```shell docker run --rm helidon-quickstart-se-jri:latest --help -``` +``` \ No newline at end of file diff --git a/examples/quickstarts/helidon-standalone-quickstart-mp/README.md b/examples/quickstarts/helidon-standalone-quickstart-mp/README.md index f14da0a9164..30297464815 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-mp/README.md +++ b/examples/quickstarts/helidon-standalone-quickstart-mp/README.md @@ -5,54 +5,50 @@ This example implements a simple Hello World REST service using MicroProfile ## Build and run -```bash +```shell mvn package java -jar target/helidon-standalone-quickstart-mp.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"message":"Hello Joe!"} -curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting +curl -X PUT -H "Content-Type: application/json" -d '{"message" : "Hola"}' http://localhost:8080/greet/greeting curl -X GET http://localhost:8080/greet/Jose -{"message":"Hola Jose!"} +#Output: {"message":"Hola Jose!"} ``` ## Try health and metrics -``` +```shell curl -s -X GET http://localhost:8080/health -{"outcome":"UP",... -. . . +#Output: {"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":... -. . . - +#Output: {"base":... ``` ## Build the Docker Image -``` +```shell docker build -t helidon-standalone-quickstart-mp . ``` ## Start the application with Docker -``` +```shell docker run --rm -p 8080:8080 helidon-standalone-quickstart-mp:latest ``` @@ -60,7 +56,7 @@ Exercise the application as described above ## Deploy the application to Kubernetes -``` +```shell kubectl cluster-info # Verify which cluster kubectl get pods # Verify connectivity to cluster kubectl create -f app.yaml # Deploy application @@ -81,7 +77,7 @@ You can build a native executable in 2 different ways: Download Graal VM at https://www.graalvm.org/downloads. -``` +```shell # Setup the environment export GRAALVM_HOME=/path # build the native executable @@ -96,7 +92,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-quickstart-mp ``` @@ -104,13 +100,13 @@ Start the application: Build the "native" Docker Image -``` +```shell docker build -t helidon-standalone-quickstart-mp-native -f Dockerfile.native . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-standalone-quickstart-mp-native:latest ``` @@ -129,7 +125,7 @@ You can build a custom JRI in two different ways: ### Local build -``` +```shell # build the JRI mvn package -Pjlink-image ``` @@ -139,7 +135,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-standalone-quickstart-mp-jri/bin/start ``` @@ -147,18 +143,18 @@ Start the application: Build the JRI as a Docker Image -``` +```shell docker build -t helidon-standalone-quickstart-mp-jri -f Dockerfile.jlink . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-standalone-quickstart-mp-jri:latest ``` See the start script help: -``` +```shell docker run --rm helidon-standalone-quickstart-mp-jri:latest --help -``` +``` \ No newline at end of file diff --git a/examples/quickstarts/helidon-standalone-quickstart-se/README.md b/examples/quickstarts/helidon-standalone-quickstart-se/README.md index 2745682f878..8b1fdc1104a 100644 --- a/examples/quickstarts/helidon-standalone-quickstart-se/README.md +++ b/examples/quickstarts/helidon-standalone-quickstart-se/README.md @@ -5,54 +5,50 @@ This project implements a simple Hello World REST service using Helidon SE with ## Build and run -```bash +```shell mvn package java -jar target/helidon-standalone-quickstart-se.jar ``` ## Exercise the application -``` +```shell curl -X GET http://localhost:8080/greet -{"message":"Hello World!"} +#Output: {"message":"Hello World!"} curl -X GET http://localhost:8080/greet/Joe -{"message":"Hello Joe!"} +#Output: {"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!"} +#Output: {"message":"Hola Jose!"} ``` ## Try health and metrics -``` -curl -s -X GET http://localhost:8080/health -{"outcome":"UP",... -. . . +```shell +curl -s -X GET http://localhost:8080/observe/health +#Output: {"outcome":"UP",... # Prometheus Format -curl -s -X GET http://localhost:8080/metrics +curl -s -X GET http://localhost:8080/observe/metrics # TYPE base:gc_g1_young_generation_count gauge -. . . # JSON Format -curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics -{"base":... -. . . - +curl -H 'Accept: application/json' -X GET http://localhost:8080/observe/metrics +#Output: {"base":... ``` ## Build the Docker Image -``` +```shell docker build -t helidon-standalone-quickstart-se . ``` ## Start the application with Docker -``` +```shell docker run --rm -p 8080:8080 helidon-standalone-quickstart-se:latest ``` @@ -60,7 +56,7 @@ Exercise the application as described above ## Deploy the application to Kubernetes -``` +```shell kubectl cluster-info # Verify which cluster kubectl get pods # Verify connectivity to cluster kubectl create -f app.yaml # Deply application @@ -82,7 +78,7 @@ You can build a native executable in 2 different ways: Download Graal VM at https://www.graalvm.org/downloads. We recommend version `23.1.0` or later. -``` +```shell # Setup the environment export GRAALVM_HOME=/path # build the native executable @@ -97,7 +93,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-standalone-quickstart-se ``` @@ -105,13 +101,13 @@ Start the application: Build the "native" Docker Image -``` +```shell docker build -t helidon-standalone-quickstart-se-native -f Dockerfile.native . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-standalone-quickstart-se-native:latest ``` @@ -130,7 +126,7 @@ You can build a custom JRI in two different ways: ### Local build -``` +```shell # build the JRI mvn package -Pjlink-image ``` @@ -140,7 +136,7 @@ See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plug Start the application: -``` +```shell ./target/helidon-standalone-quickstart-se-jri/bin/start ``` @@ -148,18 +144,18 @@ Start the application: Build the JRI as a Docker Image -``` +```shell docker build -t helidon-standalone-quickstart-se-jri -f Dockerfile.jlink . ``` Start the application: -``` +```shell docker run --rm -p 8080:8080 helidon-standalone-quickstart-se-jri:latest ``` See the start script help: -``` +```shell docker run --rm helidon-standalone-quickstart-se-jri:latest --help -``` +``` \ No newline at end of file diff --git a/examples/security/attribute-based-access-control/README.md b/examples/security/attribute-based-access-control/README.md index 3c3bbdfb813..972cb44e0d6 100644 --- a/examples/security/attribute-based-access-control/README.md +++ b/examples/security/attribute-based-access-control/README.md @@ -4,7 +4,9 @@ JAX-RS (Jersey) example for attribute based access control. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-abac.jar ``` + +Open endpoints listen in the server's output in a browser. diff --git a/examples/security/attribute-based-access-control/src/main/resources/application.yaml b/examples/security/attribute-based-access-control/src/main/resources/application.yaml index a5e8c3ef263..a6b15df009c 100644 --- a/examples/security/attribute-based-access-control/src/main/resources/application.yaml +++ b/examples/security/attribute-based-access-control/src/main/resources/application.yaml @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, 2020 Oracle and/or its affiliates. +# Copyright (c) 2017, 2024 Oracle and/or its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -58,7 +58,7 @@ security: # some-key: "some value" # another-key: "another value" - atn: - class: "io.helidon.security.examples.abac.AtnProvider" + class: "io.helidon.examples.security.abac.AtnProvider" web-server: paths: - path: "/query" diff --git a/examples/security/basic-auth-with-static-content/README.md b/examples/security/basic-auth-with-static-content/README.md index 6245dd6c7ba..3c5102cb598 100644 --- a/examples/security/basic-auth-with-static-content/README.md +++ b/examples/security/basic-auth-with-static-content/README.md @@ -13,19 +13,19 @@ There are two examples with exactly the same behavior: ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-webserver-basic-auth.jar ``` Try the application: -The application starts on a random port, the following assumes it is `56551` -```bash -curl http://localhost:56551/public -curl -u "jill:password" http://localhost:56551/noRoles -curl -u "john:password" http://localhost:56551/user -curl -u "jack:password" http://localhost:56551/admin -curl -v -u "john:password" http://localhost:56551/deny -curl -u "jack:password" http://localhost:56551/noAuthn +The application starts at the `8080` port +```shell +curl http://localhost:8080/public +curl -u "jill:password" http://localhost:8080/noRoles +curl -u "john:password" http://localhost:8080/user +curl -u "jack:password" http://localhost:8080/admin +curl -v -u "john:password" http://localhost:8080/deny +curl -u "jack:password" http://localhost:8080/noAuthn ``` diff --git a/examples/security/google-login/README.md b/examples/security/google-login/README.md index ec25bc7efd3..b4f5c355afb 100644 --- a/examples/security/google-login/README.md +++ b/examples/security/google-login/README.md @@ -19,7 +19,7 @@ Update the following files with your client id (it should support http://localho ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-google-login.jar ``` diff --git a/examples/security/idcs-login/README.md b/examples/security/idcs-login/README.md index 6f88cd17b70..5076dea8669 100644 --- a/examples/security/idcs-login/README.md +++ b/examples/security/idcs-login/README.md @@ -41,7 +41,7 @@ Edit application.yaml for IdcsMain.java or OidcConfig variable definition for Id ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-oidc.jar ``` diff --git a/examples/security/outbound-override/README.md b/examples/security/outbound-override/README.md index c24166f968a..797916cf2d8 100644 --- a/examples/security/outbound-override/README.md +++ b/examples/security/outbound-override/README.md @@ -6,15 +6,16 @@ sets the username and password. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-outbound-override.jar ``` -Try the endpoints: -```bash -curl -u "jack:password" http://localhost:8080/propagate -curl -u "jack:password" http://localhost:8080/override -curl -u "jill:anotherPassword" http://localhost:8080/propagate -curl -u "jill:anotherPassword" http://localhost:8080/override +Try the endpoints (port is random, shall be replaced accordingly): +```shell +export PORT=35973 +curl -u "jack:password" http://localhost:${PORT}/propagate +curl -u "jack:password" http://localhost:${PORT}/override +curl -u "jill:anotherPassword" http://localhost:${PORT}/propagate +curl -u "jill:anotherPassword" http://localhost:${PORT}/override ``` diff --git a/examples/security/outbound-override/src/main/java/io/helidon/security/examples/outbound/OutboundOverrideExample.java b/examples/security/outbound-override/src/main/java/io/helidon/security/examples/outbound/OutboundOverrideExample.java index d158af0fe65..3aa71ac510a 100644 --- a/examples/security/outbound-override/src/main/java/io/helidon/security/examples/outbound/OutboundOverrideExample.java +++ b/examples/security/outbound-override/src/main/java/io/helidon/security/examples/outbound/OutboundOverrideExample.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023 Oracle and/or its affiliates. + * Copyright (c) 2018, 2024 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,7 +69,8 @@ public static void main(String[] args) { Backend service started on: http://localhost:%2d/hello - """, server.port(), server.port("backend"), TimeUnit.MILLISECONDS.convert(time, TimeUnit.NANOSECONDS)); + """, TimeUnit.MILLISECONDS.convert(time, TimeUnit.NANOSECONDS), + server.port(), server.port(), server.port("backend")); } static void setup(WebServerConfig.Builder server) { diff --git a/examples/security/programmatic/README.md b/examples/security/programmatic/README.md index 3adbea5657c..cc9017e63bf 100644 --- a/examples/security/programmatic/README.md +++ b/examples/security/programmatic/README.md @@ -4,7 +4,7 @@ Example of manually using the security APIs. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-nohttp-programmatic.jar ``` diff --git a/examples/security/webserver-digest-auth/README.md b/examples/security/webserver-digest-auth/README.md index 21791c2de28..4814ae232f8 100644 --- a/examples/security/webserver-digest-auth/README.md +++ b/examples/security/webserver-digest-auth/README.md @@ -12,7 +12,7 @@ There are two examples with exactly the same behavior: ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-webserver-digest-auth.jar ``` @@ -20,11 +20,12 @@ java -jar target/helidon-examples-security-webserver-digest-auth.jar Try the application: The application starts on a random port, the following assumes it is `56551` -```bash -curl http://localhost:56551/public -curl --digest -u "jill:password" http://localhost:56551/noRoles -curl --digest -u "john:password" http://localhost:56551/user -curl --digest -u "jack:password" http://localhost:56551/admin -curl -v --digest -u "john:password" http://localhost:56551/deny -curl --digest -u "jack:password" http://localhost:56551/noAuthn +```shell +export PORT=38529 +curl http://localhost:${PORT}/public +curl --digest -u "jill:password" http://localhost:${PORT}/noRoles +curl --digest -u "john:password" http://localhost:${PORT}/user +curl --digest -u "jack:password" http://localhost:${PORT}/admin +curl -v --digest -u "john:password" http://localhost:${PORT}/deny +curl --digest -u "jack:password" http://localhost:${PORT}/noAuthn ``` diff --git a/examples/security/webserver-signatures/README.md b/examples/security/webserver-signatures/README.md index a1a1bc7b663..ad8fac058fb 100644 --- a/examples/security/webserver-signatures/README.md +++ b/examples/security/webserver-signatures/README.md @@ -16,14 +16,15 @@ There are two examples with exactly the same behavior ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-security-webserver-signatures.jar ``` -Try the endpoints: -```bash -curl -u "jack:password" http://localhost:8080/service1 -curl -u "jill:password" http://localhost:8080/service1-rsa -curl -v -u "john:password" http://localhost:8080/service1 +Try the endpoints (port is random, shall be replaced accordingly): +```shell +export PORT=34941 +curl -u "jack:password" http://localhost:${PORT}/service1 +curl -u "jill:password" http://localhost:${PORT}/service1-rsa +curl -v -u "john:password" http://localhost:${PORT}/service1 ``` diff --git a/examples/todo-app/README.md b/examples/todo-app/README.md index 43294d76d03..bdaae1f04a8 100644 --- a/examples/todo-app/README.md +++ b/examples/todo-app/README.md @@ -5,14 +5,14 @@ implemented with Helidon MP and Helidon SE. ## Build -```bash +```shell mvn clean package docker build -t helidon-examples-todo-cassandra cassandra ``` ## Run -```bash +```shell docker run -d -p 9042:9042 --name helidon-examples-todo-cassandra helidon-examples-todo-cassandra docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin java -jar backend/target/helidon-examples-todo-backend.jar & @@ -28,14 +28,14 @@ java -jar frontend/target/helidon-examples-todo-frontend.jar & If you want to run behind an HTTP proxy: -```bash +```shell export security_providers_0_google_dash_login_proxy_dash_host=proxy.acme.com export security_providers_0_google_dash_login_proxy_dash_port=80 ``` ## Stop -```bash +```shell kill %1 %2 docker rm -f zipkin helidon-examples-todo-cassandra ``` diff --git a/examples/translator-app/README.md b/examples/translator-app/README.md index e3913c42bc0..e1eea473801 100644 --- a/examples/translator-app/README.md +++ b/examples/translator-app/README.md @@ -6,18 +6,17 @@ This application demonstrates a pseudo application composed of two microservices ## Start Zipkin With Docker: -```bash +```shell docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin ``` -With Java 8+: -```bash +```shell curl -sSL https://zipkin.io/quickstart.sh | bash -s java -jar zipkin.jar ``` With Kubernetes: -```bash +```shell kubectl apply \ -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/ingress-nginx-3.15.2/deploy/static/provider/cloud/deploy.yaml \ -f ../k8s/zipkin.yaml @@ -26,7 +25,7 @@ kubectl apply \ ## Build and run With Docker: -```bash +```shell docker build -t helidon-examples-translator-backend backend/ docker build -t helidon-examples-translator-frontend frontend/ docker run --rm -d -p 9080:9080 \ @@ -40,15 +39,14 @@ docker run --rm -d -p 8080:8080 \ helidon-examples-translator-frontend:latest ``` -With Java 8+: -```bash +```shell mvn package java -jar backend/target/helidon-examples-translator-backend.jar & java -jar frontend/target/helidon-examples-translator-frontend.jar ``` Try the endpoint: -```bash +```shell curl "http://localhost:8080?q=cloud&lang=czech" curl "http://localhost:8080?q=cloud&lang=french" curl "http://localhost:8080?q=cloud&lang=italian" @@ -58,14 +56,14 @@ Then check out the traces at http://localhost:9411. ## Run with Kubernetes (docker for desktop) -```bash +```shell docker build -t helidon-examples-translator-backend backend/ docker build -t helidon-examples-translator-frontend frontend/ kubectl apply -f backend/app.yaml -f frontend/app.yaml ``` Try the endpoint: -```bash +```shell curl "http://localhost/translator?q=cloud&lang=czech" curl "http://localhost/translator?q=cloud&lang=french" curl "http://localhost/translator?q=cloud&lang=italian" @@ -74,13 +72,13 @@ curl "http://localhost/translator?q=cloud&lang=italian" Then check out the traces at http://localhost/zipkin. Stop the docker containers: -```bash +```shell docker stop zipkin \ helidon-examples-translator-backend \ helidon-examples-translator-frontend ``` Delete the Kubernetes resources: -```bash +```shell kubectl delete -f backend/app.yaml -f frontend/app.yaml ``` \ No newline at end of file diff --git a/examples/webclient/standalone/README.md b/examples/webclient/standalone/README.md index 15322eb76c4..6557e02d5fa 100644 --- a/examples/webclient/standalone/README.md +++ b/examples/webclient/standalone/README.md @@ -5,7 +5,7 @@ standalone Java program to connect to a server. ## Build -``` +```shell mvn package ``` @@ -13,7 +13,7 @@ mvn package First, start the server: -``` +```shell java -jar target/helidon-examples-webclient-standalone.jar ``` @@ -26,7 +26,7 @@ WEB server is up! http://localhost:PORT/greet Then run the client, passing the port number. It will connect to the server: -``` -java -cp "target/classes:target/libs/*" io.helidon.examples.webclient.standalone.ClientMain PORT +```shell +java -cp "target/classes:target/libs/*" io.helidon.examples.webclient.standalone.ClientMain 35963 ``` diff --git a/examples/webserver/basics/README.md b/examples/webserver/basics/README.md index 07997b01fa4..c146d43f7ff 100644 --- a/examples/webserver/basics/README.md +++ b/examples/webserver/basics/README.md @@ -8,13 +8,13 @@ methods. ## Build and run -```bash +```shell mvn package ``` To see the list of methods that are available run: -```bash +```shell java -DexampleName=help -jar target/helidon-examples-webserver-basics.jar ``` diff --git a/examples/webserver/comment-aas/README.md b/examples/webserver/comment-aas/README.md index 37f16a96890..3918c032daf 100644 --- a/examples/webserver/comment-aas/README.md +++ b/examples/webserver/comment-aas/README.md @@ -5,14 +5,14 @@ This application allows users to add or read short comments related to a single ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-webserver-comment-aas.jar ``` Try the application: -```bash +```shell curl http://localhost:8080/comments/java -d "I use Helidon!" curl http://localhost:8080/comments/java -d "I use vertx" curl http://localhost:8080/comments/java -d "I use spring" diff --git a/examples/webserver/multiport/README.md b/examples/webserver/multiport/README.md index 01810a31500..e7709a456cd 100644 --- a/examples/webserver/multiport/README.md +++ b/examples/webserver/multiport/README.md @@ -20,7 +20,7 @@ Separate routing is defined for each named socket in `Main.java` ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-webserver-multiport.jar ``` diff --git a/examples/webserver/opentracing/README.md b/examples/webserver/opentracing/README.md index f5ffcce5875..71f761b9a65 100644 --- a/examples/webserver/opentracing/README.md +++ b/examples/webserver/opentracing/README.md @@ -3,12 +3,12 @@ ## Start Zipkin With Docker: -```bash +```shell docker run --name zipkin -d -p 9411:9411 openzipkin/zipkin ``` With Java 8+: -```bash +```shell curl -sSL https://zipkin.io/quickstart.sh | bash -s java -jar zipkin.jar ``` @@ -16,26 +16,26 @@ java -jar zipkin.jar ## Build and run With Docker: -```bash +```shell docker build -t helidon-webserver-opentracing-example . docker run --rm -d --link zipkin --name helidon-webserver-opentracing-example \ -p 8080:8080 helidon-webserver-opentracing-example:latest ``` With Java 8+: -```bash +```shell mvn package java -jar target/helidon-examples-webserver-opentracing.jar ``` Try the endpoint: -```bash +```shell curl http://localhost:8080/test ``` Then check out the traces at http://localhost:9411. Stop the docker containers: -```bash +```shell docker stop zipkin helidon-webserver-opentracing-example ``` diff --git a/examples/webserver/static-content/README.md b/examples/webserver/static-content/README.md index c6c4116cfc2..45b6395a100 100644 --- a/examples/webserver/static-content/README.md +++ b/examples/webserver/static-content/README.md @@ -5,7 +5,7 @@ This application demonstrates use of the StaticContentService to serve static fi ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-webserver-static-content.jar ``` diff --git a/examples/webserver/streaming/README.md b/examples/webserver/streaming/README.md index 85085d110a7..ca171f6c584 100644 --- a/examples/webserver/streaming/README.md +++ b/examples/webserver/streaming/README.md @@ -7,13 +7,13 @@ to the size of the file being uploaded or downloaded. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-webserver-streaming.jar ``` Upload a file and download it back with `curl`: -```bash +```shell curl --data-binary "@target/classes/large-file.bin" http://localhost:8080/upload curl http://localhost:8080/download ``` diff --git a/examples/webserver/tutorial/README.md b/examples/webserver/tutorial/README.md index fcf0820db0a..89c9e6d6d74 100644 --- a/examples/webserver/tutorial/README.md +++ b/examples/webserver/tutorial/README.md @@ -4,7 +4,7 @@ This application demonstrates various WebServer use cases together and in its co ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-webserver-tutorial.jar ``` diff --git a/examples/webserver/websocket/README.md b/examples/webserver/websocket/README.md index bbf5c852767..6a1c48eb4e1 100644 --- a/examples/webserver/websocket/README.md +++ b/examples/webserver/websocket/README.md @@ -4,7 +4,7 @@ This application demonstrates use of websockets and REST. ## Build and run -```bash +```shell mvn package java -jar target/helidon-examples-webserver-websocket.jar ```