-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
server.ServeHTTP Experimental Status #7566
Comments
Yes, it is marked as experimental currently. I will confirm with the team if can remove experimental status |
There are no plans to stabilize the functionality. gRPC's HTTP/2 server provides more features than the Go HTTP server and we haven't yet heard any critical use cases that require the Go HTTP server, so it's hard to justify spending time improving it. |
@ekky-kharismadhany do you have any specific use case that's relevant here? |
Hi, sorry for the late reply I currently working on some application that use grpc-gateway project. On those projects, my organization uses same port to serve RESTful API and gRPC. The current implementation is using a third-party library which currently does not have any update for the last 3 years. So, I'm searching a method to handle this issue and found that That being said, do you have any recommendation or experience on how an application can serve both RESTful and gRPC at the same port? Thank you |
Another way I used that API was by wrapping it with an HTTP middleware it could serve also grpc-web requests. It required h2 also for grpc-web requests, but it worked well for unary and server streaming RPCs. There are some implementations that offer also grpc-web, it might be considered. |
Hi @isgj , I also use h2c for my proof-of-concept code. It works well. server := grpc.NewServer(opts...)
reflection.Register(server)
echo_rpc.RegisterEchoServerServer(server, initServer())
logger.Info("server started", "host", host)
multiServer := http.Server{
Handler: h2c.NewHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.ProtoMajor == 2 && r.Header.Get("content-type") == "application/grpc" {
server.ServeHTTP(w, r)
} else {
mux.ServeHTTP(w, r)
}
}), &http2.Server{}),
}
if err := multiServer.Serve(listener); err != nil {
panic(err.Error())
} |
Better approach would be to have a proxy or custom middleware for routing traffic accordingly. Alternatively, you can consider libraries like cmux to multiplex connections based on their payload |
Hi @purnesh42H cmux is the third-party project I referred to earlier in this issue. I'm looking for an alternative to cmux. But your approach on using proxy or a custom middleware is interesting. Could you elaborate those approaches, please? Thank you |
@ekky-kharismadhany you can have a custom proxy which does the routing based on if request is http/grpc. you can implement the dialing logic in your custom dialer to connect to the proxy and then forward the traffic. See here https://github.com/grpc/grpc-go/blob/master/Documentation/proxy.md Alternatively, is it not possible for you to have just grpc service and have a gateway to do automatic transcoding of converting http request to grpc and grpc response to http? |
Hi @purnesh42H I will take a look at this https://github.com/grpc/grpc-go/blob/master/Documentation/proxy.md. Thank you Unfortunately, my organization already use grpc-gateway to handle automatic transcoding between http request and grpc response. Thus, adding one in front of our service will adds more layer to the app. I thank you for your help. |
Hi
I would like to ask whether the
server.ServeHTTP
is still on the experimental status. It's been 7 years since the experimental status is added to codebase #1429.Thank you for the help
The text was updated successfully, but these errors were encountered: