johanbrandhorst / grpc-gateway-boilerplate

All the boilerplate you need to get started with writing grpc-gateway powered REST services in Go
MIT License
479 stars 83 forks source link

How to use w/ Java Server #30

Closed lsmith24 closed 2 years ago

lsmith24 commented 3 years ago

Hi, when I run the command for a standalone server I get a transient failure message. I'm kind of confused how to incorporate my own server, I have the address/port that the server is running on but I don't see how to get the gateway to point to it. Any help would be great thanks!

johanbrandhorst commented 3 years ago

Hi! To run the standalone example you have to use the --server-address flag, like so:

$ go run ./cmd/standalone/ --server-address dns:///0.0.0.0:10000

You can replace the IP (0.0.0.0) and port (10000) as necessary. Note that your backend server will also need to be instrumented with the generated stubs for your relevant language for the protobuf file in the repository, the instructions of which is outside the scope of this repository.

What error are you seeing?

lsmith24 commented 3 years ago

My Java project uses gradle, I cannot find how to include the dependencies for gateway with gradle? When I put the imports that are shown in the example proto file into my own proto file it cannot find the proper files for the second one (the openapi one)

johanbrandhorst commented 3 years ago

You'll need to either copy the protobuf dependencies explicitly into your workspace or use buf (as this repo does) to manage the dependency for you.

lsmith24 commented 3 years ago

Is there an equivalent for gradle?

johanbrandhorst commented 3 years ago

There is not... yet. At Buf (where I work) we're working on integrating automatic remote generation with things like Maven. But for now you will have to read the Java gRPC quickstart: https://grpc.io/docs/languages/java/quickstart/