You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/12/02 09:37:31 UTC

[GitHub] [apisix] tokers commented on a diff in pull request #8364: fix: proxy grpc sometimes occurs 502

tokers commented on code in PR #8364:
URL: https://github.com/apache/apisix/pull/8364#discussion_r1037952551


##########
t/grpc_server_example/main.go:
##########
@@ -217,6 +223,21 @@ func (s *server) Run(ctx context.Context, in *pb.Request) (*pb.Response, error)
 	return &pb.Response{Body: in.User.Name + " " + in.Body}, nil
 }
 
+func gRPCAndHTTPFunc(grpcServer *grpc.Server) http.Handler {
+	return h2c.NewHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+		mux := http.NewServeMux()
+		mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+			w.Write([]byte("hello http"))
+		})
+
+		if r.ProtoMajor == 2 && strings.Contains(r.Header.Get("Content-Type"), "application/grpc") {

Review Comment:
    Try the https://pkg.go.dev/github.com/brankas/netmux.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org