johanbrandhorst/grpc-gateway-boilerplate
소개
grpc-gateway 기반 Go REST 서비스를 개발하는 데 필요한 보일러플레이트 전체
기타 프로젝트측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalgrpc-gateway-boilerplate
All the boilerplate you need to get started with writing grpc-gateway powered REST services in Go.
Requirements
Go 1.17+
Running
Running main.go starts a web server on https://0.0.0.0:11000/. You can configure
the port used with the $PORT environment variable, and to serve on HTTP set
$SERVE_HTTP=true.
$ go run main.go
An OpenAPI UI is served on https://0.0.0.0:11000/.
Running the standalone server
If you want to use a separate gRPC server, for example one written in Java or C++, you can run the standalone web server instead:
$ go run ./cmd/standalone/ --server-address dns:///0.0.0.0:10000
Getting started
After cloning the repo, there are a couple of initial steps;
- If you forked this repo, or cloned it into a different directory from the github structure,
you will need to correct the import paths. Here's a nice
findone-liner for accomplishing this (replaceyourscmprovider.com/youruser/yourrepowith your cloned repo path):$ find . -path ./vendor -prune -o -type f \( -name '*.go' -o -name '*.proto' -o -name '*.yaml' \) -exec sed -i -e "s;github.com/johanbrandhorst/grpc-gateway-boilerplate;yourscmprovider.com/youruser/yourrepo;g" {} + - Finally, generate the files with
make generate.
Now you can run the web server with go run main.go.
Making it your own
The next step is to define the interface you want to expose in
proto/users/v1/user.proto. See https://developers.google.com/protocol-buffers/
tutorials and guides on writing Protobuf files. See the Buf
style guide
for tips on how to structure your packages.
Once that is done, regenerate the files using
make generate. This will mean you'll need to implement any functions in
server/server.go, or else the build will fail since your struct won't
be implementing the interface defined by the generated files anymore.
This should hopefully be all you need to get started playing around with the gRPC-Gateway!
관련 프로젝트 살펴보기
불러오는 중…