项目作者: jrapoport

项目描述 :
Chrome & Firefox Browser extension to aid gRPC-Web development using native gRPC-Web interceptors.
高级语言: JavaScript
项目地址: git://github.com/jrapoport/grpc-web-devtools.git
创建时间: 2020-12-10T05:14:19Z
项目社区:https://github.com/jrapoport/grpc-web-devtools

开源协议:MIT License

下载


gRPC-Web Dev Tools: Interceptor Edition

PRs Welcome
GitHub

Buy Me A Coffee

gRPC-Web Dev Tools
Now supports dark mode.

gRPC-Web Interceptor Support

This fork of grpc-web-devtools
adds support for native gRPC-Web interceptors.

SafetyCulture’s previous version
was incompatible with other gRPC-Web interceptors and broke them — which made
debugging things like JWT authorization over gRPC-Web impossible.

This version fixes that by reimplementing the extension as a pair of native
gRPC-Web interceptors. Now you can include the debug interceptors alongside
the other gRPC-Web interceptors in your chain, and it “just works”.

I also added a new icon to indicate when a stream has ended (vs. the call
returning).

Currently, a unary gRPC-Web callback uses the same internal gRPC-Web code path
as a streaming call (as opposed to a unary promise). As a result, the unary
callback appears as a streaming call in the debug panel.

NOTE: This is a breaking change.

NEW Usage

  1. const devInterceptors = window.__GRPCWEB_DEVTOOLS__ || (() => {});
  2. const {
  3. devToolsUnaryInterceptor,
  4. devToolsStreamInterceptor,
  5. } = devInterceptors();
  6. const opts = {
  7. unaryInterceptors: [devToolsUnaryInterceptor],
  8. streamInterceptors: [devToolsStreamInterceptor],
  9. };
  10. const client = new EchoServiceClient('http://myapi.com', null, opts);

Installation

Chrome

Via the Chrome Web Store (recommended)

or

  1. build it with make build
  2. open the Extension Management page by navigating to chrome://extensions.
  3. enable Developer Mode by clicking the toggle switch next to “Developer mode”.
  4. Click the LOAD UNPACKED button and select the extension ./build directory.

Firefox

Via Firefox Browser Add-Ons (recommended)

or

  1. build and package with make package
  2. enter about:debugging in the URL bar of Firefox
  3. click This Firefox > Load Temporary Add-on…
  4. select the grpc-web-devtools.zip extention file

Usage

  1. const devInterceptors = window.__GRPCWEB_DEVTOOLS__ || (() => {});
  2. const {
  3. devToolsUnaryInterceptor,
  4. devToolsStreamInterceptor,
  5. } = devInterceptors();
  6. const opts = {
  7. unaryInterceptors: [devToolsUnaryInterceptor],
  8. streamInterceptors: [devToolsStreamInterceptor],
  9. };
  10. const client = new EchoServiceClient('http://myapi.com', null, opts);

NOTE:
Requires clients use grpc-web >= 1.2.1 & that your generated client(s) use protoc-gen-grpc-web >= 1.2.1

protoc-gen-grpc-web v1.3.0 is bundled
(disabled temporarily pending arm64 macOS support)

Example

The example uses docker-compose to start a simple gRPC server, JavaScript
client and the Envoy proxy for gRPC-Web:

  1. make example-up

Example will be running on http://localhost:8080

To stop the example:

  1. make example-down