Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactoring mapping name #2168

Merged
merged 1 commit into from Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions gateway/config.go
Expand Up @@ -11,12 +11,12 @@ type (
// GatewayConf is the configuration for gateway.
GatewayConf struct {
rest.RestConf
Upstreams []upstream
Upstreams []Upstream
Timeout time.Duration `json:",default=5s"`
}

// mapping is a mapping between a gateway route and a upstream rpc method.
mapping struct {
// RouteMapping is a mapping between a gateway route and an upstream rpc method.
RouteMapping struct {
// Method is the HTTP method, like GET, POST, PUT, DELETE.
Method string
// Path is the HTTP path.
Expand All @@ -25,14 +25,14 @@ type (
RpcPath string
}

// upstream is the configuration for upstream.
upstream struct {
// Grpc is the target of upstream.
// Upstream is the configuration for an upstream.
Upstream struct {
// Grpc is the target of the upstream.
Grpc zrpc.RpcClientConf
// ProtoSet is the file of proto set, like hello.pb
ProtoSet string `json:",optional"`
// Mapping is the mapping between gateway routes and upstream rpc methods.
// Mapping is the mapping between gateway routes and Upstream rpc methods.
// Keep it blank if annotations are added in rpc methods.
Mapping []mapping `json:",optional"`
Mapping []RouteMapping `json:",optional"`
}
)
6 changes: 3 additions & 3 deletions gateway/server.go
Expand Up @@ -23,7 +23,7 @@ type (
// Server is a gateway server.
Server struct {
*rest.Server
upstreams []upstream
upstreams []Upstream
timeout time.Duration
processHeader func(http.Header) []string
}
Expand Down Expand Up @@ -63,7 +63,7 @@ func (s *Server) build() error {
source <- up
}
}, func(item interface{}, writer mr.Writer, cancel func(error)) {
up := item.(upstream)
up := item.(Upstream)
cli := zrpc.MustNewClient(up.Grpc)
source, err := s.createDescriptorSource(cli, up)
if err != nil {
Expand Down Expand Up @@ -138,7 +138,7 @@ func (s *Server) buildHandler(source grpcurl.DescriptorSource, resolver jsonpb.A
}
}

func (s *Server) createDescriptorSource(cli zrpc.Client, up upstream) (grpcurl.DescriptorSource, error) {
func (s *Server) createDescriptorSource(cli zrpc.Client, up Upstream) (grpcurl.DescriptorSource, error) {
var source grpcurl.DescriptorSource
var err error

Expand Down