-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,352 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
proto: ## protoc | ||
protoc -I/usr/local/include -I$(GOPATH)/src/github.com/googleapis/googleapis\ | ||
--proto_path=$(GOPATH)/src:. --go_out=. --go-http_out=. --go-grpc_out=.\ | ||
example/greeter/v1/hello.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
# protoc-gen-go-http | ||
generate go http server code via proto buffer | ||
|
||
## how to use | ||
|
||
```shell | ||
$ make proto | ||
# or | ||
$ protoc -I/usr/local/include -I$(GOPATH)/src/github.com/googleapis/googleapis\ | ||
--proto_path=$(GOPATH)/src:. --go_out=. --go-http_out=. --go-grpc_out=.\ | ||
path/to/file.proto | ||
``` | ||
|
||
## TODO | ||
|
||
- [ ] support [validate](https://github.com/envoyproxy/protoc-gen-validate) | ||
- [ ] gen client code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package greeter | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gin-gonic/gin" | ||
"google.golang.org/grpc" | ||
|
||
v1 "github.com/yusank/protoc-gen-go-http/example/greeter/v1" | ||
) | ||
|
||
// Greeter implement v1.HelloServer and v1.HelloHTTPHandler at same time | ||
type Greeter struct { | ||
v1.UnimplementedHelloServer | ||
} | ||
|
||
func (g *Greeter) Add(ctx context.Context, in *v1.AddRequest) (*v1.AddResponse, error) { | ||
panic("implement me") | ||
} | ||
|
||
func (g *Greeter) Get(ctx context.Context, in *v1.GetRequest) (*v1.GetResponse, error) { | ||
panic("implement me") | ||
} | ||
|
||
func register() { | ||
// can call method by rpc or http | ||
v1.RegisterHelloServer(&grpc.Server{}, &Greeter{}) | ||
v1.RegisterHelloHTTPHandler(gin.Default().Group("/"), &Greeter{}) | ||
} |
Oops, something went wrong.