You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+76-19Lines changed: 76 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,38 +21,45 @@ Check also the [RESTHeart Greetings Services Tutorial](https://restheart.org/doc
21
21
22
22
🚀 To run and develop this project you can now use the new [RESTHeart command line interface](https://github.com/SoftInstigate/restheart-cli/tree/master). It provides a convenient interface for watching for code changes and automatically rebuilding/redeploying RESTHeart plugins.
23
23
24
-
After you have installed the cli, follow its [Usage Guide](https://github.com/SoftInstigate/restheart-cli/blob/master/usage-guide.md). It explains how to start from this plugin skeleton to create a __continuous development process__.
24
+
After you have installed the cli, follow its [Usage Guide](https://github.com/SoftInstigate/restheart-cli/blob/master/usage-guide.md). It explains how to start from this plugin skeleton to create a **continuous development process**.
25
25
26
26
### Run with Docker
27
27
28
28
Follow these steps if you prefer to set up and run the project with docker:
> **Note:** The `-s` option (**standalone mode**) disables MongoDB-dependent plugins. Use this option if you do not intend to connect to a MongoDB instance during runtime.
44
49
45
50
Test the service using:
46
51
47
52
With curl:
53
+
48
54
```bash
49
-
$ curl localhost:8080/srv
55
+
curl localhost:8080/srv
50
56
{"message":"Hello World!","rnd":"njXZksfKFW"}%
51
57
```
52
58
53
59
With httpie:
60
+
54
61
```bash
55
-
$ http -b :8080/srv
62
+
http -b :8080/srv
56
63
{
57
64
"message": "Hello World!",
58
65
"rnd": "KvQGBwsPBp"
@@ -68,23 +75,29 @@ $ http -b :8080/srv
68
75
To run RESTHeart with MongoDB, follow these steps:
69
76
70
77
1. Launch a MongoDB container:
78
+
71
79
```bash
72
-
$ docker run -d --name mongodb -p 27017:27017 mongo --replSet=rs0
80
+
docker run -d --name mongodb -p 27017:27017 mongo --replSet=rs0
73
81
```
82
+
74
83
2. Initialize MongoDB as a Single Node Replica Set:
> **Note:** The `-s` option is not used here to enable MongoDB-dependent plugins.
84
96
85
97
Test a simple GET request:
98
+
86
99
```bash
87
-
$ curl -u admin:secret localhost:8080/users
100
+
curl -u admin:secret localhost:8080/users
88
101
```
89
102
90
103
For more details, check the [REST API Tutorial](https://restheart.org/docs/mongodb-rest/tutorial) and the [GraphQL Tutorial](https://restheart.org/docs/mongodb-graphql/tutorial).
@@ -96,17 +109,19 @@ For more details, check the [REST API Tutorial](https://restheart.org/docs/mongo
96
109
The default configuration is used. The environment variable `RHO` can be used to override the configuration. See [Change the configuration in Docker container](https://restheart.org/docs/configuration#change-the-configuration-in-docker-container)
| Standalone demo (no MongoDB) |_(none)_ or `security`/`metrics` as needed |\`./mvnw clean package\`|\`docker run --pull=always --name restheart --rm -p "8080:8080" -v ./target:/opt/restheart/plugins/custom softinstigate/restheart -s\`|
226
+
| MongoDB development (insecure dev only) |`mongodb`|\`./mvnw clean package -Pmongodb\`|\`docker run -d --name mongodb -p 27017:27017 mongo --replSet=rs0\` then \`docker exec mongodb mongosh --quiet --eval "rs.initiate()"\` then \`docker run --name restheart --rm -p "8080:8080" -v ./target:/opt/restheart/plugins/custom softinstigate/restheart\`|
227
+
| Secured MongoDB API |`security,mongodb`|\`./mvnw clean package -Psecurity,mongodb\`| Same as MongoDB development (without `-s`) |
228
+
| GraphQL over MongoDB |`graphql,mongodb` (add `security` if needed) |\`./mvnw clean package -Pgraphql,mongodb\`| Same as MongoDB development (without `-s`) |
229
+
| Metrics enabled |`metrics` (+ combine with others) |\`./mvnw clean package -Pmetrics\`| Combine with your chosen run mode |
230
+
| Native executable (bundles RESTHeart + plugin) |`native` (+ combine modules at build time is not supported; native already bundles required RESTHeart artifacts) |\`sdk install java 21.0.3-graal\` then \`./mvnw clean package -Pnative\`|\`RHO="/fullAuthorizer/enabled->true" target/restheart-plugin-skeleton\`|
231
+
232
+
Notes:
233
+
234
+
- Docker `-s` flag runs in standalone mode (disables MongoDB-dependent plugins). Do not use `-s` when you enable `mongodb` profile.
235
+
- In default (non-`native`) builds, RESTHeart core dependencies are treated as `provided`; your plugin JAR plus `target/lib` contains only external runtime deps.
236
+
- Avoid heavy static initializers in plugins to keep GraalVM native-image builds smooth.
237
+
238
+
---
239
+
240
+
## Debugging & Logs
241
+
242
+
- RESTHeart logs to stdout/stderr in Docker and to console in native runs. Inspect container logs for plugin issues:
243
+
244
+
```bash
245
+
docker logs -f restheart
246
+
```
247
+
248
+
- If your service returns `405`, verify the HTTP method handling in `src/main/java/org/restheart/examples/HelloWorldService.java` and ensure `OPTIONS` is handled via `handleOptions(req)` for CORS.
249
+
- To adjust service behavior at runtime, prefer `RHO` env overrides instead of code changes (e.g., `/helloWorldService/message`).
0 commit comments