Skip to content

Commit

Permalink
README.md validations
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <[email protected]>
  • Loading branch information
senivam committed Jun 20, 2024
1 parent c7f7811 commit 9f2dbdb
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void run() {

private static void logSecrets(Config secrets) {
LOGGER.info("Loaded secrets are u: " + secrets.get("username").asString().get()
+ ", p: " + secrets.get("changeit").asString().get());
+ ", p: " + secrets.get("password").asString().get());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static void main(String... args) {
System.out.println("Username: " + username);
assert username.equals("libor");

String password = secrets.get("changeit").asString().get();
String password = secrets.get("password").asString().get();
System.out.println("Password: " + password);
assert password.equals("changeit");
}
Expand Down
23 changes: 16 additions & 7 deletions examples/cors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ These normal greeting app endpoints work just as in the original greeting app:

```shell
curl -X GET http://localhost:8080/greet
{"message":"Hello World!"}
#{"message":"Hello World!"}

curl -X GET http://localhost:8080/greet/Joe
{"message":"Hello Joe!"}
#{"message":"Hello Joe!"}

curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting

curl -X GET http://localhost:8080/greet/Jose
{"message":"Hola Jose!"}
#{"message":"Hola Jose!"}
```

## Using CORS
Expand All @@ -49,6 +49,8 @@ By setting `Origin` and `Host` headers that do not indicate the same system we t
# Follow the CORS protocol for GET
curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet

```
```text
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json
Expand All @@ -66,6 +68,8 @@ The same happens for a `GET` requesting a personalized greeting (by passing the
```shell
curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet/Joe

```
```text
HTTP/1.1 200 OK
Date: Wed, 31 Jan 2024 11:58:06 +0100
Access-Control-Allow-Origin: *
Expand Down Expand Up @@ -98,7 +102,8 @@ curl -i -X OPTIONS \
-H "Origin: http://foo.com" \
-H "Host: here.com" \
http://localhost:8080/greet/greeting

```
```text
HTTP/1.1 200 OK
Date: Wed, 31 Jan 2024 12:00:15 +0100
Access-Control-Allow-Methods: PUT
Expand All @@ -119,7 +124,8 @@ curl -i -X PUT \
-H "Content-Type: application/json" \
-d "{ \"greeting\" : \"Cheers\" }" \
http://localhost:8080/greet/greeting

```
```text
HTTP/1.1 204 No Content
Date: Wed, 31 Jan 2024 12:01:45 +0100
Access-Control-Allow-Origin: http://foo.com
Expand All @@ -130,7 +136,8 @@ Vary: ORIGIN
And we run one more `GET` to observe the change in the greeting:
```shell
curl -i -X GET -H "Origin: http://foo.com" -H "Host: here.com" http://localhost:8080/greet/Joe

```
```text
HTTP/1.1 200 OK
Date: Wed, 31 Jan 2024 12:02:13 +0100
Access-Control-Allow-Origin: *
Expand All @@ -157,6 +164,8 @@ curl -i -X OPTIONS \
-H "Origin: http://other.com" \
-H "Host: here.com" \
http://localhost:8080/greet/greeting
```
```text
HTTP/1.1 403 CORS origin is not in allowed list
Date: Wed, 31 Jan 2024 12:02:51 +0100
Connection: keep-alive
Expand All @@ -171,7 +180,7 @@ mvn package
java -jar target/helidon-examples-cors.jar
```
Send the previous `OPTIONS` request again and note the successful result:
```shell
```text
HTTP/1.1 200 OK
Date: Wed, 31 Jan 2024 12:05:36 +0100
Access-Control-Allow-Methods: PUT
Expand Down
10 changes: 5 additions & 5 deletions examples/dbclient/jdbc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Uncomment the appropriate configuration in the application.xml for the desired d

## Build

```
```shell
mvn package
```

This example may also be run as a GraalVM native image in which case can be built using the following:

```
```shell
mvn package -Pnative-image
```

Expand All @@ -30,18 +30,18 @@ Instructions for H2 can be found here: http://www.h2database.com/html/cheatSheet
Instructions for Oracle can be found here: https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance

MySQL can be run as a docker container with the following command:
```
```shell
docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=changeit mysql:5.7
```


Then run the application:

```
```shell
java -jar target/helidon-examples-dbclient-jdbc.jar
```
or in the case of native image
```
```shell
./target/helidon-examples-dbclient-jdbc
```

Expand Down
6 changes: 3 additions & 3 deletions examples/dbclient/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ This example shows how to run Helidon DB over mongoDB.

## Build

```
```shell
mvn package
```

## Run

This example requires a mongoDB database, start it using docker:

```
```shell
docker run --rm --name mongo -p 27017:27017 mongo
```

Then run the application:

```
```shell
java -jar target/helidon-examples-dbclient-mongodb.jar
```

Expand Down
22 changes: 11 additions & 11 deletions examples/dbclient/pokemons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ To switch between JDBC drivers:
## Build

To build a jar file
```
```shell
mvn package
```

To build a native image (supported only with Oracle, MongoDB, or H2 databases)
```
```shell
mvn package -Pnative-image
```

Expand All @@ -53,19 +53,19 @@ Start your database before running this example.
Example docker commands to start databases in temporary containers:

Oracle:
```
```shell
docker run --rm --name xe -p 1521:1521 -p 8888:8080 wnameless/oracle-xe-11g-r2
```
For details on an Oracle Docker image, see https://github.com/oracle/docker-images/tree/master/OracleDatabase/SingleInstance

H2:
```
```shell
docker run --rm --name h2 -p 9092:9082 -p 8082:8082 nemerosa/h2
```
For details, see http://www.h2database.com/html/cheatSheet.html

MySQL:
```
```shell
docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root \
-e MYSQL_DATABASE=pokemon -e MYSQL_USER=user -e MYSQL_PASSWORD=changeit mysql:5.7
```
Expand All @@ -74,24 +74,24 @@ docker run --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root \
## Run

Then run the `io.helidon.examples.dbclient.pokemons.Main` class:
```
```shell
java -jar target/helidon-examples-dbclient-pokemons.jar
```

Or run the native image:
```
```shell
./target/helidon-examples-dbclient-pokemons
```

### Run with MongoDB

It's possible to run example with MongoDB database. Start it using docker:
```
```shell
docker run --rm --name mongo -p 27017:27017 mongo
```

Then run the `io.helidon.examples.dbclient.pokemons.Main` class with `mongo` argument:
```
```shell
java -jar target/helidon-examples-dbclient-pokemons.jar mongo
```

Expand All @@ -106,7 +106,7 @@ The application has the following endpoints:
Application also connects to zipkin on default address.
The query operation adds database trace.

```
```shell
# List all Pokémon
curl http://localhost:8080/db/pokemon

Expand All @@ -132,7 +132,7 @@ curl -i -X DELETE http://localhost:8080/db/pokemon/7
### Proxy

Make sure that `localhost` is not being accessed trough proxy when proxy is configured on your system:
```
```shell
export NO_PROXY='localhost'
```

Expand Down
16 changes: 8 additions & 8 deletions examples/employee-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ CREATE SEQUENCE EMPLOYEE_SEQ INCREMENT BY 1 NOCACHE NOCYCLE;

## Exercise the application
Get all employees.
```sh
```shell
curl -X GET curl -X GET http://localhost:8080/employees
```

Expand All @@ -60,7 +60,7 @@ Only 1 output record is shown for brevity:


Get all employees whose last name contains "S".
```sh
```shell
curl -X GET http://localhost:8080/employees/lastname/S
```

Expand All @@ -81,7 +81,7 @@ Only 1 output record is shown for brevity:
```

Get an individual record.
```sh
```shell
curl -X GET http://localhost:8080/employees/48cf06ad-6ed4-47e6-ac44-3ea9c67cbe2d
```
Output:
Expand All @@ -108,7 +108,7 @@ http://localhost:8080/public/index.html

## Try health and metrics

```sh
```shell
curl -s -X GET http://localhost:8080/health
```

Expand Down Expand Up @@ -150,7 +150,7 @@ curl -s -X GET http://localhost:8080/health

### Prometheus Format

```sh
```shell
curl -s -X GET http://localhost:8080/metrics
```

Expand All @@ -162,7 +162,7 @@ base:classloader_current_loaded_class_count 3995
```

### JSON Format
```sh
```shell
curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
```

Expand Down Expand Up @@ -210,13 +210,13 @@ Output:

## Build the Docker Image

```sh
```shell
docker build -t employee-app .
```

## Start the application with Docker

```sh
```shell
docker run --rm -p 8080:8080 employee-app:latest
```

Expand Down
10 changes: 6 additions & 4 deletions examples/graphql/basics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ Probe the GraphQL endpoints:
1. Hello word endpoint:

```shell
curl -X POST http://127.0.0.1:PORT/graphql -d '{"query":"query { hello }"}'
export PORT='41667'
curl -X POST http://127.0.0.1:${PORT}/graphql -d '{"query":"query { hello }"}'

"data":{"hello":"world"}}
#"data":{"hello":"world"}}
```

1. Hello in different languages

```shell
curl -X POST http://127.0.0.1:PORT/graphql -d '{"query":"query { helloInDifferentLanguages }"}'
export PORT='41667'
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"]}}
#{"data":{"helloInDifferentLanguages":["Bonjour","Hola","Zdravstvuyte","Nǐn hǎo","Salve","Gudday","Konnichiwa","Guten Tag"]}}
```
4 changes: 2 additions & 2 deletions examples/integrations/cdi/datasource-hikaricp-mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ running in this Docker container, verify that the following lines
(among others) are present in
`src/main/resources/META-INF/microprofile-config.properties`:

```sh
```properties
javax.sql.DataSource.example.dataSourceClassName=com.mysql.cj.jdbc.MysqlDataSource
javax.sql.DataSource.example.dataSource.url = jdbc:mysql://localhost:3306
javax.sql.DataSource.example.dataSource.user = root
Expand All @@ -46,7 +46,7 @@ java -jar target/helidon-integrations-examples-datasource-hikaricp-mysql.jar
```

Try the endpoint:
```sh
```shell
curl http://localhost:8080/tables
```

Expand Down
2 changes: 1 addition & 1 deletion examples/integrations/micrometer/mp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ curl -X GET http://localhost:8080/greet/Joe
```

```shell
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
#Output: {"message":"Hola Jose!"}
Expand Down
Loading

0 comments on commit 9f2dbdb

Please sign in to comment.