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

Can I also use grpc-web? #23

Closed
yehudamakarov opened this issue Jan 5, 2021 · 2 comments
Closed

Can I also use grpc-web? #23

yehudamakarov opened this issue Jan 5, 2021 · 2 comments

Comments

@yehudamakarov
Copy link

I'm trying to figure out how I would ALSO be able to open up a way for the mux to grab http 1.1 requests that are sendt via grpc-web.

It's not an issue, but I'm asking for some help, even for a good place to gather wisdom from.

See grpc-web:

grpcServer := grpc.Server()
wrappedGrpc := grpcweb.WrapServer(grpcServer)
tlsHttpServer.Handler = http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
    if wrappedGrpc.IsGrpcWebRequest(req) {
	    wrappedGrpc.ServeHTTP(resp, req)
    }
    // Fall back to other servers.
    http.DefaultServeMux.ServeHTTP(resp, req)
})

I'm going to be trying it soon, but I'm still working on some architecture, and now I realize this has to be possible but I don't know how yet.

@johanbrandhorst
Copy link
Owner

Hi @yehudamakarov. It should certainly be possible to use grpc-web at the same time, though I would personally suggest settling on one solution. You can see my grpcweb-example repo for an example of using the Improbable in-process grpc-web proxy with a Go gRPC server.

If you want some reading material, I suggest reading my blog post from a few years ago, it's still pretty accurate: https://grpc.io/blog/state-of-grpc-web/. I don't think I'm going to add grpc-web support to this repo, so I'm going to close this issue. Feel free to reach out on Gophers Slack if you need more help.

@yehudamakarov
Copy link
Author

Thank you @johanbrandhorst, I appreciate the reply, as well as your work and talks.

Reading through both of your example projects is putting it all together.

Also, I didn't even realize Google had their own grpc-web. So your article was great for context.

All the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants