hi, Zexuan
yes, remove strip_path in the configuration will be better.
thanks for your reference.

Zexuan Luo <spacewan...@apache.org> 于2021年12月24日周五 10:18写道:

> > 1. When grpc-web client sends a request, it will generate a route
> according
> to the package.service.function rule in the .proto file defined. If we want
> to access through "/example/*" instead of "/*" when setting up the route,
> the URI we get in the gateway at this time is
> "/example/package.service.function", but grpc Server needs "
> package.service.function", so the user can use "strip_path" to decide
> whether to delete the prefix.
>
> It sounds that we need to always remove the prefix in this case. As
> "/example/package.service.function" isn't valid proto name.
> Maybe we can use the code in
>
> https://github.com/apache/apisix/blob/3c0c89a58ee872c9564ded3fe6e8998f96235489/apisix/plugins/serverless/generic-upstream.lua#L76
> ,
> which strips the path automatically if it is matched by the wildcard.
>
> JinChao Shuai <shuaijinc...@apache.org> 于2021年12月23日周四 18:40写道:
> >
> > hi, chao
> >
> > 1. When grpc-web client sends a request, it will generate a route
> according
> > to the package.service.function rule in the .proto file defined. If we
> want
> > to access through "/example/*" instead of "/*" when setting up the route,
> > the URI we get in the gateway at this time is
> > "/example/package.service.function", but grpc Server needs "
> > package.service.function", so the user can use "strip_path" to decide
> > whether to delete the prefix.
> >
> > 2. There is an introduction about the agreement in the link [5].
> > The JavaScript client provides two data transmission methods.
> > The first is the text method. We need to determine the encryption method
> > through the mimetype in the gateway, then use its corresponding
> decryption
> > method to decrypt, reset it to the body, and forward it to the upstream
> > request. After grpcServer responds, it needs to be encrypted in the same
> > way to respond to the client.
> > Data in another binary format can be forwarded directly, and the gateway
> > only needs to process CORS and the conversion of requests and responses
> > mime.
> >
> >
> > Chao Zhang <tok...@apache.org> 于2021年12月23日周四 16:23写道:
> >
> > > Hi!
> > >
> > > Sounds good to me, but still I want to pick your brain to resolve some
> > > confusions.
> > >
> > > 1. I'm confused with the `strip_path` field, could you give some more
> > > elaborated examples?
> > > 2. Still don't know how Apache APISIX can support such protocol
> > > conversion. How does Apache APISIX convert the data in gRPC web format
> > > to gRPC format?
> > >
> > > Best regards
> > > Chao Zhang
> > >
> > > https://github.com/tokers
> > >
> > > On Thu, Dec 23, 2021 at 4:00 PM JinChao Shuai <shuaijinc...@apache.org
> >
> > > wrote:
> > > >
> > > > Hi, folks
> > > >
> > > > gRPC was originally developed by Google and is a high-performance
> remote
> > > > procedure call framework based on HTTP/2 implementation. But because
> the
> > > > browser does not directly expose HTTP/2, Web applications cannot
> directly
> > > > use gRPC.
> > > > gRPC-Web is a standardized protocol that solves this problem. You
> can use
> > > > gRPC in the browser and provide a JavaScript implementation of gRPC
> for
> > > the
> > > > browser client.
> > > > The principle is to create an end-to-end gRPC pipeline that is
> compatible
> > > > with HTTP/1.1 and HTTP/2, and then the browser sends a regular HTTP
> > > request
> > > > to the gRPC-Web between the browser and the server The proxy
> converts the
> > > > request and response.
> > > >
> > > > Currently Envoy provides proxy and conversion capabilities of the
> > > gRPC-Web
> > > > protocol. I think Apache APISIX can provide friendly proxy support
> for
> > > > gRPC-Web through plugin, which is meaningful to front-end
> developers. You
> > > > can use a more native way to develop microservices or applications
> based
> > > on
> > > > gRPC.
> > > >
> > > > The following are the relevant configuration and technical details.
> > > >
> > > > Plugin Name:
> > > >
> > > > - grpc-web
> > > >
> > > >
> > > > Plugin Configuration:
> > > >
> > > > {
> > > >     "strip_path":false
> > > > }
> > > >
> > > > strip_path: strip request routing prefix, If set to true, stripped
> > > request
> > > > path will be passed to upstream gRPC service
> > > >
> > > >
> > > > Detail:
> > > >
> > > > 1、What Apache APISIX needs to do ?
> > > >
> > > > gRPC-Web Client  <-->  Proxy  <--> gRPC Service
> > > >
> > > > Implement Proxy, complete the decoding of data from gRPC-Web data to
> gRPC
> > > > Server and the encoding of gRPC Server response to gRPC-Web.
> > > >
> > > > 2、Data Format: Use the protoc-gen-grpc-web plugin to generate proto
> > > > messages and the service client stub from your .proto
> > > >
> > > > 2.1 protoc-gen-grpc-web mode=grpcwebtext: The default generated code
> > > sends
> > > > the payload in the grpc-web-text format.
> > > > - Content-type: application/grpc-web-text
> > > > - Payload are base64-encoded.
> > > > - Both unary and server streaming calls are supported.
> > > >
> > > > 2.2 protoc-gen-grpc-web mode=grpcweb: A binary protobuf format is
> also
> > > > supported.
> > > > - Content-type: application/grpc-web+proto
> > > > - Payload are in the binary protobuf format.
> > > > - Only unary calls are supported for now.
> > > >
> > > > refer to: [1]
> > > >
> > > > 3、CORS Support:
> > > >
> > > > 3.1 Should follow the CORS spec (Mandatory)
> > > > - Access-Control-Allow-Credentials to allow Authorization headers
> > > > - Access-Control-Allow-Methods to allow POST and (preflight) OPTIONS
> only
> > > > - Access-Control-Allow-Headers to whatever the preflight request
> carries
> > > >
> > > > 3.2 The client library is expected to support header overwrites to
> avoid
> > > > preflight
> > > >
> > > > 3.3 CSP support to be specified
> > > >
> > > > refer to: [2]
> > > >
> > > > For more information and use about grpc-web protocol, please refer
> to:
> > > > [3]、[4]、[5]
> > > >
> > > > [1]
> > > >
> > >
> https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md#protocol-differences-vs-grpc-over-http2
> > > > [2]
> > > >
> > >
> https://github.com/grpc/grpc-web/blob/master/doc/browser-features.md#cors-support
> > > > [3] https://www.npmjs.com/package/grpc-web
> > > > [4]
> https://github.com/grpc/grpc-web/blob/master/doc/browser-features.md
> > > > [5] https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md
> > > >
> > > >
> > > > --
> > > > Thanks,
> > > > Janko
> > >
> >
> >
> > --
> > Thanks,
> > Janko
>


-- 
Thanks,
Janko

Reply via email to