Discover Packages
github.com/johanbrandhorst/rust-grpc-web-wasm-test
command
module
Version:
v0.0.0-...-cca32d8
Opens a new window with list of versions in this module.
Published: Oct 27, 2019
License: MIT
Opens a new window with license information.
Imports: 13
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
README
¶
rust-grpc-web-wasm-test
Currently supported
A go gRPC-web server with the built-in Improbable proxy. Run with:
$ go run main.go
There's one flag, --html-root
, which can be used to specify
which directory to serve the frontend from. The Go gRPC backend
has been sprinkled with helpful log messages throughout, which should
hopefully aid in debugging any problems.
Remaining work
Manually implement the Rust WASM client to call the gRPC-Web API.
The following API calls are supported (here presented as JS Fetch calls):
GetBook:
await fetch("https://localhost:8080/library.BookService/GetBook", {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0",
"Accept": "*/*",
"Accept-Language": "en-GB,en;q=0.5",
"content-type": "application/grpc-web+proto", // Content-Type
"x-grpc-web": "1",
},
"referrer": "https://localhost:8080/",
"body": "\u0000\u0000\u0000\u0000\u0005\b½·áB", // binary protobuf body
// ^----^ // Compression flag, 1 byte
// ^----------------------^ // Size of body, 4 bytes
// ^----^ // Body
"method": "POST",
"mode": "cors"
});
QueryBooks (stream):
await fetch("https://localhost:8080/library.BookService/QueryBooks", {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0",
"Accept": "*/*",
"Accept-Language": "en-GB,en;q=0.5",
"content-type": "application/grpc-web+proto",
"x-grpc-web": "1",
},
"referrer": "https://localhost:8080/",
"body": "\u0000\u0000\u0000\u0000\b\n\u0006George", // binary protobuf body
// ^----^ // Compression flag, 1 byte
// ^--------------------------^ // Size of body, 4 bytes
// ^----^ // Body
"method": "POST",
"mode": "cors"
});
After successful manual unary and server streaming requests are handled,
move to implement Rust WASM protobuf generator.
Iterate on designs until ready to share.
Further reading:
gRPC-Web protocol spec: https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md
Official JS gRPC-Web client (XHR based): https://github.com/grpc/grpc-web/tree/master/javascript/net/grpc/web
Improbable TypeScript gRPC-Web client (Fetch and XHR based): https://github.com/improbable-eng/grpc-web/tree/master/client/grpc-web/src
Dart gRPC-Web client (XHR based): https://github.com/grpc/grpc-dart/commit/91564ff7aa33214b55d050bed44be1b875a6713b
Expand ▾
Collapse ▴
Documentation
¶
There is no documentation for this package.
Source Files
¶
Directories
¶
proto
Click to show internal directories.
Click to hide internal directories.