feat: restful -> grpc gateway (#2155)
* Revert "chore: remove unimplemented gateway (#2139)"
This reverts commit d70e73ec66.
* feat: working gateway
* feat: use mr to make it faster
* feat: working gateway
* chore: add comments
* feat: support protoset besides reflection
* feat: support zrpc client conf
* docs: update readme
* feat: support grpc-metadata- header to gateway- header conversion
* chore: add docs
This commit is contained in:
56
gateway/readme.md
Normal file
56
gateway/readme.md
Normal file
@@ -0,0 +1,56 @@
|
||||
# Gateway
|
||||
|
||||
## Usage
|
||||
|
||||
- main.go
|
||||
|
||||
```go
|
||||
var configFile = flag.String("f", "config.yaml", "config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c gateway.GatewayConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
gw := gateway.MustNewServer(c)
|
||||
defer gw.Stop()
|
||||
gw.Start()
|
||||
}
|
||||
```
|
||||
|
||||
- config.yaml
|
||||
|
||||
```yaml
|
||||
Name: demo-gateway
|
||||
Host: localhost
|
||||
Port: 8888
|
||||
Upstreams:
|
||||
- Grpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- localhost:2379
|
||||
Key: hello.rpc
|
||||
# protoset mode
|
||||
ProtoSet: hello.pb
|
||||
Mapping:
|
||||
- Method: get
|
||||
Path: /pingHello/:ping
|
||||
Rpc: hello.Hello/Ping
|
||||
- Grpc:
|
||||
Endpoints:
|
||||
- localhost:8081
|
||||
# reflection mode, no ProtoSet settings
|
||||
Mapping:
|
||||
- Method: post
|
||||
Path: /pingWorld
|
||||
Rpc: world.World/Ping
|
||||
```
|
||||
|
||||
## Generate ProtoSet files
|
||||
|
||||
- example command
|
||||
|
||||
```shell
|
||||
protoc --descriptor_set_out=hello.pb hello.proto
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user