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:
35
gateway/config.go
Normal file
35
gateway/config.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type (
|
||||
// GatewayConf is the configuration for gateway.
|
||||
GatewayConf struct {
|
||||
rest.RestConf
|
||||
Upstreams []upstream
|
||||
Timeout time.Duration `json:",default=5s"`
|
||||
}
|
||||
|
||||
// mapping is a mapping between a gateway route and a upstream rpc method.
|
||||
mapping struct {
|
||||
// Method is the HTTP method, like GET, POST, PUT, DELETE.
|
||||
Method string
|
||||
// Path is the HTTP path.
|
||||
Path string
|
||||
// Rpc is the gRPC rpc method, with format of package.service/method
|
||||
Rpc string
|
||||
}
|
||||
// upstream is the configuration for upstream.
|
||||
upstream struct {
|
||||
// Grpc is the target of upstream.
|
||||
Grpc zrpc.RpcClientConf
|
||||
// ProtoSet is the file of proto set, like hello.pb
|
||||
ProtoSet string `json:",optional"`
|
||||
Mapping []mapping
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user