Skip to content

Commit

Permalink
format grpc gateway options
Browse files Browse the repository at this point in the history
  • Loading branch information
yinheli committed Aug 6, 2021
1 parent acb3aa0 commit 3046a59
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions core/xservice/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,17 @@ func (t *serverImpl) initGrpc() {
healthServer.SetServingStatus(t.options.Name, healthpb.HealthCheckResponse_SERVING)
healthpb.RegisterHealthServer(g, healthServer)

t.grpcGateway = gwrt.NewServeMux(gwrt.WithRoutingErrorHandler(
func(ctx context.Context, mux *gwrt.ServeMux, m gwrt.Marshaler, w http.ResponseWriter, r *http.Request, status int) {
switch status {
case http.StatusNotFound:
t.echo.ServeHTTP(w, r)
default:
gwrt.DefaultRoutingErrorHandler(ctx, mux, m, w, r, status)
}
},
))
t.grpcGateway = gwrt.NewServeMux(
gwrt.WithRoutingErrorHandler(
func(ctx context.Context, mux *gwrt.ServeMux, m gwrt.Marshaler, w http.ResponseWriter, r *http.Request, status int) {
switch status {
case http.StatusNotFound:
t.echo.ServeHTTP(w, r)
default:
gwrt.DefaultRoutingErrorHandler(ctx, mux, m, w, r, status)
}
},
))

// echo instance for grpc-gateway, which wrap another echo instance, for gRPC service not found fallback serve
e := t.newEcho("grpc_gateway")
Expand Down

0 comments on commit 3046a59

Please sign in to comment.