File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
examples/connectrpc_grpc_servers Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 3
3
This example demonstrates the pattern of starting both a gRPC server and a ConnectRPC server in the same component on
4
4
different ports.
5
5
6
+ The logic behind is that gRPC server is used for internal communication, while ConnectRPC server is proxied by a reverse
7
+ proxy to handle external http requests coming from the frontend.
8
+
6
9
Example shows that the same service is run by both servers, and the gRPC server is used to handle
7
10
gRPC requests, while the ConnectRPC server is used to handle ConnectRPC requests.
8
11
9
12
Dependencies are wired using [ Cedi] ( https://github.com/igor-vovk/cedi ) library.
10
13
11
14
Testing the ConnectRPC server:
15
+
12
16
1 . Start the server by running:
17
+
13
18
``` bash
14
19
sbt example_connectrpc_grpc_servers/run
15
20
```
21
+
16
22
2 . Use ` curl ` to send http requests to the ConnectRPC server:
23
+
17
24
``` bash
18
25
curl -X POST http://localhost:8080/examples.v1.ElizaService/Say -d ' {"sentence": "Hello Connectrpc"}' -H ' Content-Type: application/json'
19
26
```
You can’t perform that action at this time.
0 commit comments