Giter Club home page Giter Club logo

Comments (9)

purnesh42H avatar purnesh42H commented on September 7, 2024

Yes, it is marked as experimental currently. I will confirm with the team if can remove experimental status

from grpc-go.

dfawley avatar dfawley commented on September 7, 2024

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.

from grpc-go.

purnesh42H avatar purnesh42H commented on September 7, 2024

@ekky-kharismadhany do you have any specific use case that's relevant here?

from grpc-go.

ekky-kharismadhany avatar ekky-kharismadhany commented on September 7, 2024

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 server.ServeHTTP can be used to solve my organization issue.

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

from grpc-go.

isgj avatar isgj commented on September 7, 2024

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.

from grpc-go.

ekky-kharismadhany avatar ekky-kharismadhany commented on September 7, 2024

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())
	}

from grpc-go.

purnesh42H avatar purnesh42H commented on September 7, 2024

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

from grpc-go.

ekky-kharismadhany avatar ekky-kharismadhany commented on September 7, 2024

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

from grpc-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.