Open yinzara opened 4 years ago
I highly suggest adding "grpc-web" support to your microservice. That will allow any web browser to connect directly to the service using gRPC without having to use RESTful JSON.
See: "github.com/improbable-eng/grpc-web/go/grpcweb"
handler = grpcweb.WrapHandler(handler, grpcweb.WithCorsForRegisteredEndpointsOnly(false), grpcweb.WithOriginFunc(func(origin string) bool { return true }), grpcweb.WithAllowNonRootResource(false), )
I also suggest adding cors support as well as an option.
See: "github.com/rs/cors"
handler = cors.New(cors.Options{ AllowedMethods: []string{ http.MethodHead, http.MethodGet, http.MethodPost, http.MethodPut, http.MethodPatch, http.MethodDelete, }, AllowOriginFunc: func(origin string) bool { return true }, AllowedHeaders: []string{"*"}, AllowCredentials: true, }).Handler(handler)
And if you need unencrypted HTTP 2.0 support.
See: "golang.org/x/net/http2" "golang.org/x/net/http2/h2c"
handler = h2c.NewHandler(handler, &http2.Server{})
Nice suggestions! I'll do some reading :) Thanks
I highly suggest adding "grpc-web" support to your microservice. That will allow any web browser to connect directly to the service using gRPC without having to use RESTful JSON.
See: "github.com/improbable-eng/grpc-web/go/grpcweb"
I also suggest adding cors support as well as an option.
See: "github.com/rs/cors"
And if you need unencrypted HTTP 2.0 support.
See: "golang.org/x/net/http2" "golang.org/x/net/http2/h2c"