This application provides an API sample that I use to play with Gravitee APIM.
To launch tests:
./gradlew test
To run application in Dev mode:
./gradlew --console=plain quarkusDev
To build the application:
./gradlew build docker
It starts a single http server to handle
-
regular HTTP request.
-
WebSockets.
-
GRPC services.
This HTTP endpoint can receive HTTP request. It will copy the request received in a 200 response.
Using httpie:
http POST http://localhost:8888/echo\?qs\=value message=Hello
will respond
{
"body": {
"message": "Hello"
},
"headers": {
"Accept": "application/json, */*;q=0.5",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"Content-Length": "20",
"Content-Type": "application/json",
"Host": "localhost:8888",
"User-Agent": "HTTPie/3.2.1"
},
"method": "POST",
"query_params": {
"qs": "value"
}
}
This endpoint can receive WebSocket request. It will copy the request received in the response.
Using websocat:
websocat -1 ws://localhost:8888/ws/echo {"message": "Hello"}
will respond
{
"type": "json",
"request": {
"message": "Hello"
}
}
The application provides 2 gRPC services adapted from gRPC examples:
-
the Route Guide service
-
the Greeter service
The Route Guide service shows the various kind of gRPC service calls:
-
simple RPC
-
server-side streaming RPC
-
client-side streaming RPC
-
bidirectional streaming RPC
Proto files are available at
-
or it can be downloaded using the HTTP server: http://localhost:8888/proto/route_guide.proto or http://localhost:8888/proto/helloworld.proto
Using grpcurl. (The server exposes Reflection service, therefore no need to provide the protofile to the client)
grpcurl -d '{"latitude": 413628156, "longitude": -749015468}' -plaintext localhost:8888 routeguide.RouteGuide/GetFeature
will respond
{
"name": "U.S. 6, Shohola, PA 18458, USA",
"location": {
"latitude": 413628156,
"longitude": -749015468
}
}
The application provides a GraphQL endpoint. It exposes the schema through http://localhost:8888/graphql/schema.graphql